結果
問題 | No.316 もっと刺激的なFizzBuzzをください |
ユーザー |
![]() |
提出日時 | 2019-09-30 22:00:48 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 1,483 bytes |
コンパイル時間 | 1,049 ms |
コンパイル使用メモリ | 161,192 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-03 05:27:27 |
合計ジャッジ時間 | 2,243 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 33 |
ソースコード
#include <bits/stdc++.h>using namespace std;typedef unsigned long long ull;typedef long long ll;typedef pair<int, int> pii;typedef pair<ll, ll> pll;typedef pair<double, double> pdd;const ull mod = 1e9 + 7;#define REP(i,n) for(int i=0;i<(int)n;++i)//debug#define dump(x) cerr << #x << " = " << (x) << endl;#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){os << "(" << v.first << ", " << v.second << ")"; return os;}template<class T> ostream& operator << (ostream& os, const vector<T> v){for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;}template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;}ll Euclid(ll A, ll B){if(A<B) swap(A, B);ll C = B;while(C != 0){C = A%B;A = B;B = C;}return A;}int main(){cin.tie(0);ios::sync_with_stdio(false);ll N;cin >> N;vector<ll> x(3, 0);REP(i, 3) cin >> x[i];ll res = 0;REP(i, 8){if(i==0) continue;ll tmp = 1;ll cnt = 0;REP(j, 3){if(i>>j&1){tmp = tmp*x[j]/Euclid(tmp, x[j]);cnt++;}}ll sign = (cnt%2==0 ? -1 : 1);res += sign * (N/tmp);}cout << res << endl;return 0;}