結果
問題 | No.316 もっと刺激的なFizzBuzzをください |
ユーザー |
|
提出日時 | 2024-05-15 00:59:18 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 14 ms / 1,000 ms |
コード長 | 1,276 bytes |
コンパイル時間 | 4,155 ms |
コンパイル使用メモリ | 251,220 KB |
最終ジャッジ日時 | 2025-02-21 14:03:40 |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 33 |
ソースコード
#include <bits/stdc++.h> // clang-format off #include <atcoder/all> using namespace std; using namespace atcoder; #define rep(i,n) for(int i=0;i<(n);i++) template<class T,class S>inline bool chmax(T &a,const S &b) {return (a<b? a=b,1:0);} template<class T,class S>inline bool chmin(T &a,const S &b) {return (a>b? a=b,1:0);} template<class T,class S>inline T floor(T a,S b) {if(b<0)a=-a,b=-b;return a>=0?a/b:(a+1)/b-1;} template<class T,class S>inline T ceil(T a,S b) {if(b<0)a=-a,b=-b;return a>0?(a-1)/b+1:a/b;} constexpr int dx[8]={1,0,-1,0,1,-1,1,-1},dy[8]={0,1,0,-1,1,-1,-1,1}; using ll = long long; // clang-format on #ifdef LOCAL #include <util/debug_print.hpp> #else #define debug(...) static_cast<void>(0) #endif ll gcd(ll a, ll b) { return (b == 0) ? a : gcd(b, a % b); } ll lcm(ll a, ll b) { return a / gcd(a, b) * b; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); ll n; cin >> n; vector<ll> A(3); rep(i, 3) cin >> A[i]; ll ans = 0; rep(bit, 1 << 3) { if (bit == 0) continue; ll x = 1; rep(i, 3) { if (bit >> i & 1) x = lcm(x, A[i]); } if (__builtin_popcount(bit) % 2) ans += n / x; else ans -= n / x; } cout << ans << '\n'; return 0; }