結果
問題 | No.316 もっと刺激的なFizzBuzzをください |
ユーザー |
![]() |
提出日時 | 2019-07-06 01:40:08 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 477 bytes |
コンパイル時間 | 612 ms |
コンパイル使用メモリ | 65,944 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-22 14:30:57 |
合計ジャッジ時間 | 1,651 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 33 |
ソースコード
#include<iostream>#include<algorithm>using namespace std;using lint=int64_t;template<typename T>T gcd(T a,T b){if(a==0 || b==0)return 0;T r;while(1){r=a%b;if(r==0)break;a=b;b=r;}return b;}template<typename T>T lcm(T a,T b){if(a==0 || b==0)return 0;return a*(b/gcd(a,b));}int main(){lint N;lint a,b,c;cin >> N;cin >> a >> b >> c;cout << N/a+N/b+N/c-N/lcm(a,b)-N/lcm(b,c)-N/lcm(c,a)+N/lcm(a,lcm(b,c)) << endl;return 0;}