結果
問題 | No.316 もっと刺激的なFizzBuzzをください |
ユーザー |
|
提出日時 | 2017-06-18 12:19:13 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 689 bytes |
コンパイル時間 | 803 ms |
コンパイル使用メモリ | 73,084 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-01 19:42:19 |
合計ジャッジ時間 | 2,061 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 33 |
ソースコード
#include<cstdio>#include <iostream>#include<algorithm>#include<string>#include<queue>#include<vector>#include<functional>#include<cmath>#include<map>#include<stack>#include<set>#include<numeric>using namespace std;typedef long long ll;typedef pair<ll, ll> Pr;ll n, a, b, c;ll gcd(ll a, ll b) {while (b != 0) {a = a % b;swap(a, b);}return a;}ll lcm(ll x, ll y) {return x*y / gcd(x, y);}int main(){cin >> n >> a >> b >> c;ll A = n / a;ll B = n / b;ll C = n / c;ll AB = n / lcm(a,b);ll BC = n / lcm(b,c);ll CA = n / lcm(c,a);ll ABC = n / lcm(lcm(a,b),c);ll ans = A + B + C - AB - BC - CA + ABC;printf("%lld\n",ans);return 0;}