結果
問題 | No.316 もっと刺激的なFizzBuzzをください |
ユーザー |
![]() |
提出日時 | 2015-12-09 00:02:18 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 771 bytes |
コンパイル時間 | 634 ms |
コンパイル使用メモリ | 73,784 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-21 11:18:28 |
合計ジャッジ時間 | 1,762 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 33 |
ソースコード
#include <iostream>#include <vector>#include <cstdio>#include <sstream>#include <map>#include <string>#include <algorithm>#include <queue>#include <cmath>#include <set>using namespace std;long long gcd(long long a, long long b){if(b==0) return a;return gcd(b, a%b);}long long lcm(long long a, long long b){if(a<b) swap(a,b);if(b==1) return a;return a * (b/gcd(a,b));}long long extgcd(long long a, long long b, long long &x, long long &y){long long d=a;if(b!=0){d = extgcd(b, a%b, y, x);y -= (a/b) * x;}else{x = 1;y = 0;}return d;}int main(){int n;cin >> n;int a,b,c;cin >> a >> b >> c;int ans = n/a + n/b + n/c - n/lcm(a,b) - n/lcm(b,c) - n/lcm(c,a) + n/lcm(a,lcm(b,c));cout << ans << endl;return 0;}