結果
問題 | No.316 もっと刺激的なFizzBuzzをください |
ユーザー |
|
提出日時 | 2015-12-20 12:00:04 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 1,101 bytes |
コンパイル時間 | 794 ms |
コンパイル使用メモリ | 92,572 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-21 12:12:05 |
合計ジャッジ時間 | 1,905 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 33 |
ソースコード
#include <cstdio>#include <iostream>#include <sstream>#include <fstream>#include <iomanip>#include <algorithm>#include <cmath>#include <string>#include <vector>#include <list>#include <queue>#include <stack>#include <set>#include <map>#include <bitset>#include <numeric>#include <limits>#include <climits>#include <cfloat>#include <functional>using namespace std;// 最大公約数long long gcd(long long a, long long b){while(b != 0){long long tmp = a % b;a = b;b = tmp;}return a;}// 最小公倍数long long lcm(long long a, long long b){return a / gcd(a, b) * b;}int main(){int n;cin >> n;vector<int> a(3);for(int i=0; i<3; ++i)cin >> a[i];long long ans = 0;for(int i=1; i<(1<<3); ++i){bitset<3> bs(i);long long x = 1;for(int j=0; j<3; ++j){if(bs[j])x = lcm(x, a[j]);}if(bs.count() % 2 == 0)ans -= n / x;elseans += n / x;}cout << ans << endl;return 0;}