結果
問題 | No.316 もっと刺激的なFizzBuzzをください |
ユーザー | naimonon77 |
提出日時 | 2015-12-18 17:07:57 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 616 bytes |
コンパイル時間 | 1,338 ms |
コンパイル使用メモリ | 159,780 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-21 12:08:16 |
合計ジャッジ時間 | 2,492 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 33 |
ソースコード
#include <bits/stdc++.h> #define REP(i,a,b) for(i=a;i<b;i++) #define rep(i,n) REP(i,0,n) using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double ld; /* ここからが本編 */ /* */ ull gcd(ull m, ull n) { if(m < n) swap(m,n); // m >= n while(n) { ull tmp = n; n = m % n; m = tmp; } return m; } ull lcm(ull m,ull n) { return m*(n/gcd(m,n)); } int main(void) { int i,j,k; ull n; ull a,b,c; ull ans; cin >> n >> a >> b >> c; 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; }