結果
| 問題 | 
                            No.3179 3 time mod
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2025-06-13 21:36:29 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 20 ms / 2,000 ms | 
| コード長 | 2,132 bytes | 
| コンパイル時間 | 1,646 ms | 
| コンパイル使用メモリ | 194,856 KB | 
| 実行使用メモリ | 7,844 KB | 
| 最終ジャッジ日時 | 2025-06-14 01:39:15 | 
| 合計ジャッジ時間 | 3,475 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 42 | 
ソースコード
#include<bits/stdc++.h>
using namespace std;
template<long long mod>
struct modint{
  long long v;
  modint(long long x=0):v((x%=mod)<0?x+mod:x){}
  constexpr long long val()noexcept{return v;}
  constexpr modint& operator=(const modint o){v=o.v;return *this;}
  constexpr modint& operator+=(const modint o)noexcept{if((v+=o.v)>=mod)v-=mod;return *this;}
  constexpr modint& operator-=(const modint o)noexcept{if((v-=o.v)<0)v+=mod;return *this;}
  constexpr modint& operator*=(const modint o)noexcept{v=v*o.v%mod;return *this;}
  constexpr modint& operator/=(modint o)noexcept{return *this*=o.inv();}
  constexpr modint pow(long long n)noexcept{
    modint ret=1,base=*this;
    while(n>0){if(n&1)ret*=base;base*=base;n/=2;}
    return ret;
  }
  constexpr modint inv()noexcept{return pow(mod-2);}
  constexpr modint operator+(const modint o)noexcept{return modint(*this)+=o;}
  constexpr modint operator+()noexcept{return *this;}
  constexpr modint operator-(const modint o)noexcept{return modint(*this)-=o;}
  constexpr modint operator-()noexcept{return modint()-*this;}
  constexpr modint operator*(const modint o)noexcept{return modint(*this)*=o;}
  constexpr modint operator/(const modint o)noexcept{return modint(*this)/=o;}
  constexpr modint& operator++()noexcept{return *this+=1;}
  constexpr modint operator++(int)noexcept{return (*this+=1)-1;}
  constexpr modint& operator--()noexcept{return *this-=1;}
  constexpr modint operator--(int)noexcept{return (*this-=1)+1;}
  constexpr bool operator==(const modint o)noexcept{return v==o.v;}
  constexpr bool operator!=(const modint o)noexcept{return v!=o.v;}
  friend ostream& operator<<(ostream& os,const modint o)noexcept{os<<o.v;return os;}
};
using mint=modint<998244353>;
int main(){
  long long n;
  cin>>n;
  long long p,q,r;
  cin>>p>>q>>r;
  long long a,b,c;
  cin>>a>>b>>c;
  long long tx=0;
  for(long long x=0;x<q;x++){
    if(p*x%q==((b-a)%q+q)%q) tx=x;
  }
  long long ty=0;
  for(long long y=0;y<r;y++){
    if(p*q%r*y%r==((c-a-p*tx%r)%r+r)%r) ty=y;
  }
  long long rem=(p*q*ty+p*tx+a)%(p*q*r);
  if(n<rem) cout<<0<<endl;
  else cout<<(n-rem)/(p*q*r)+1<<endl;
}