結果
| 問題 | 
                            No.3179 3 time mod
                             | 
                    
| コンテスト | |
| ユーザー | 
                             miztom
                         | 
                    
| 提出日時 | 2025-06-13 21:42:26 | 
| 言語 | PyPy3  (7.3.15)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 39 ms / 2,000 ms | 
| コード長 | 299 bytes | 
| コンパイル時間 | 332 ms | 
| コンパイル使用メモリ | 82,180 KB | 
| 実行使用メモリ | 54,020 KB | 
| 最終ジャッジ日時 | 2025-06-14 01:40:00 | 
| 合計ジャッジ時間 | 3,039 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 42 | 
ソースコード
import math
def crt(a,b,x,y):
    g=math.gcd(x,y)
    if(b-a)%g!=0:return-1
    X,Y,R=x//g,-y//g,(b-a)//g
    inv=pow(X,-1,Y)*R%Y
    return(x*inv+a)%abs(x*y//g)
n=int(input())
p,q,r=map(int,input().split())
a,b,c=map(int,input().split())
x=crt(a,b,p,q);x=crt(x,c,p*q,r)
y=p*q*r;print(n//y+(n%y>=x))
            
            
            
        
            
miztom