結果
問題 | No.316 もっと刺激的なFizzBuzzをください |
ユーザー |
👑 |
提出日時 | 2019-04-20 09:55:51 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 779 bytes |
コンパイル時間 | 678 ms |
コンパイル使用メモリ | 72,536 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-25 07:40:08 |
合計ジャッジ時間 | 1,828 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 33 |
ソースコード
#include <cstdio>#include <cstdlib>#include <cstddef>#include <vector>#include <algorithm>#include <cmath>#include <string>#include <iostream>#include <iomanip>#define L64 long longL64 getgcd(L64 a, L64 b) {while (0 < a && 0 < b) {if (a < b)b = b % a;elsea = a % b;}return std::max(a, b);}L64 getlcm(L64 a, L64 b){L64 gcd = getgcd(a, b);return (a / gcd) * b;}int main(void){L64 n, a, b, c, res;std::cin >> n >> a >> b >> c;res = n / a + n / b + n / c;L64 lcm_ab, lcm_bc, lcm_ca, lcm_all;lcm_ab = getlcm(a, b);lcm_bc = getlcm(b, c);lcm_ca = getlcm(c, a);res -= (n / lcm_ab + n / lcm_bc + n / lcm_ca);lcm_all = getlcm(lcm_ab, c);res += n / lcm_all;std::cout << res << std::endl;return 0;}