結果
問題 |
No.3179 3 time mod
|
ユーザー |
|
提出日時 | 2025-09-18 11:49:16 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 12 ms / 2,000 ms |
コード長 | 719 bytes |
コンパイル時間 | 5,751 ms |
コンパイル使用メモリ | 335,056 KB |
実行使用メモリ | 7,720 KB |
最終ジャッジ日時 | 2025-09-18 11:49:24 |
合計ジャッジ時間 | 7,361 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 42 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) #define all(x) (x).begin(), (x).end() using ll = long long; const ll MOD = 998244353; #include<atcoder/all> using namespace atcoder; using mint = modint998244353; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); ll n,p,q,r,a,b,c;cin>>n>>p>>q>>r>>a>>b>>c; if(p<q){ swap(p,q); swap(a,b); } ll cnt=0; while((p*cnt+a-b)%q!=0)cnt++; ll pp=lcm(p,q),aa=(p*cnt+a); if(pp<r){ swap(pp,r); swap(aa,c); } cnt=0; while((pp*cnt+aa-c)%r!=0)cnt++; ll rr=lcm(pp,r),cc=(pp*cnt+aa); if(cc>n){ cout<<0<<endl; return 0; } cout<<max(0LL,(n-cc)/rr)+1<<endl; }