結果
問題 |
No.316 もっと刺激的なFizzBuzzをください
|
ユーザー |
![]() |
提出日時 | 2022-01-26 13:38:57 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 22 ms / 1,000 ms |
コード長 | 1,096 bytes |
コンパイル時間 | 2,212 ms |
コンパイル使用メモリ | 198,424 KB |
最終ジャッジ日時 | 2025-01-27 15:23:10 |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 33 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; using P = pair<int, int>; using T = tuple<int, int, int>; #define al(a) a.begin(), a.end() #define ral(a) a.rbegin(), a.rend() #define sz(a) (int)a.size() #define rep(i, n) for (int i = 0; i < (n); ++i) #define rrep(i, n) for (int i = 1; i <= (n); ++i) #define drep(i, n) for (int i = (n)-1; i >= 0; --i) #define db(a, b) cout << #a << ": " << a << " " << #b << ": " << b << endl; int main() { int n; cin >> n; vector<ll> a(3); rep(i, 3) cin >> a[i]; sort(al(a)); // vector<int> b; // rep(i, 3) { // bool d = false; // rep(j, i) if (a[i] % a[j] == 0) d = true; // if (!d) b.push_back(a[i]); // } ll ans = 0; int m = sz(a); int m2 = 1 << m; rep(s, m2) { if (s == 0) continue; ll now = 0; rep(i, 3) if (s >> i & 1) { if (!now) now = a[i]; else now = lcm(now, a[i]); } ll cnt = n / now; int bit = __builtin_popcount(s); if (bit % 2 == 0) cnt = -cnt; // db(s, cnt); ans += cnt; } cout << ans << endl; return 0; }