結果
| 問題 | No.316 もっと刺激的なFizzBuzzをください |
| コンテスト | |
| ユーザー |
しらっ亭
|
| 提出日時 | 2015-12-17 02:20:37 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 1,000 ms |
| コード長 | 1,397 bytes |
| 記録 | |
| コンパイル時間 | 2,143 ms |
| コンパイル使用メモリ | 158,332 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-21 12:06:34 |
| 合計ジャッジ時間 | 2,517 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 33 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); i--)
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i,n) for (int i = (n)-1; i >= 0; i--)
#define ALL(x) (x).begin(), (x).end()
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define MP(x,y) make_pair((x), (y))
#define MIN(a,b) (a > b ? b : a)
#define MAX(a,b) (a > b ? a : b)
#define MOD 1000000007
typedef long long ll;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define bitcount(b) __builtin_popcount(b)
#define GCD(a,b) (__gcd(a,b))
#define GCD3(a,b,c) (GCD(GCD(a,b), c))
#define LCM(a,b) (a/GCD(a,b)*b)
#define LCM3(a,b,c) LCM(LCM(a,b),c)
// -------------------------------------
long N, a, b, c;
int main() {
cin >> N >> a >> b >> c;
long na = N / a;
long nb = N / b;
long nc = N / c;
long ab = LCM(a, b);
long bc = LCM(b, c);
long ca = LCM(c, a);
long nab = N / ab;
long nbc = N / bc;
long nca = N / ca;
long abc = LCM3(a, b, c);
long nabc = N / abc;
cout << na + nb + nc - nab - nbc - nca + nabc << endl;
return 0;
}
しらっ亭