結果

問題 No.3179 3 time mod
ユーザー D M
提出日時 2025-09-18 11:47:05
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 658 bytes
コンパイル時間 5,416 ms
コンパイル使用メモリ 335,040 KB
実行使用メモリ 7,720 KB
最終ジャッジ日時 2025-09-18 11:47:13
合計ジャッジ時間 7,830 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 41 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#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);
    cout<<max(0LL,(n-cc)/rr)+1<<endl;
}
0