結果
問題 | No.316 もっと刺激的なFizzBuzzをください |
ユーザー |
![]() |
提出日時 | 2025-01-31 17:38:52 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 827 bytes |
コンパイル時間 | 3,085 ms |
コンパイル使用メモリ | 133,000 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2025-01-31 17:38:58 |
合計ジャッジ時間 | 4,929 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 33 |
ソースコード
#include <iostream>#include <vector>#include <algorithm>#include <atcoder/all>using namespace std;using namespace atcoder;using ll = long long;using mint = modint998244353;#define all(a) (a).begin(), (a).end()#define rep(i, n) for (int i = 0; i< (int)(n); i++)int inf = 1e9+7;int gcd(int a, int b){if(a < b)swap(a, b);if(b == 0)return a;return gcd(b, a%b);}int lcm(int a, int b){int c = a/gcd(a, b);if(c <= inf/b){return b*c;}else{return inf;}}int main(){ios::sync_with_stdio(false);std::cin.tie(nullptr);int n, a, b, c; cin >> n >> a >> b >> c;int ans = n/a + n/b + n/c;ans -= n/lcm(a, b) + n/lcm(b, c) + n/lcm(a, c);int lab = lcm(a, b);int labc = lcm(lab, c);ans += n/labc;cout << ans << endl;return 0;}