結果
問題 | No.316 もっと刺激的なFizzBuzzをください |
ユーザー |
![]() |
提出日時 | 2017-07-20 20:30:51 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 764 bytes |
コンパイル時間 | 845 ms |
コンパイル使用メモリ | 88,548 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-08 17:56:29 |
合計ジャッジ時間 | 1,873 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 33 |
ソースコード
#include <algorithm>#include <cstdio>#include <iostream>#include <map>#include <cmath>#include <queue>#include <set>#include <sstream>#include <stack>#include <string>#include <vector>#include <stdlib.h>#include <stdio.h>#include <bitset>using namespace std;#define FOR(I,A,B) for(int I = (A); I < (B); ++I)typedef long long ll;//最大公約数ll gcd(ll a, ll b) {while (a && b) {if (a >= b) a %= b;else b %= a;}return a + b;}//最小公倍数ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b;}int main(){ll N,a,b,c;cin>>N>>a>>b>>c;ll ans = 0;ans += N / a + N / b + N / c;ans -= N / lcm(a, b);ans -= N / lcm(b, c);ans -= N / lcm(c, a);ans += N / lcm(lcm(a,b),c);cout << ans << endl;return 0;}