結果

問題 No.186 中華風 (Easy)
ユーザー parukiparuki
提出日時 2016-08-27 11:51:40
言語 PyPy3
(7.3.15)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 721 bytes
コンパイル時間 938 ms
コンパイル使用メモリ 86,996 KB
実行使用メモリ 71,400 KB
最終ジャッジ日時 2023-08-09 20:27:15
合計ジャッジ時間 4,004 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,240 KB
testcase_01 AC 71 ms
71,284 KB
testcase_02 AC 74 ms
71,072 KB
testcase_03 AC 69 ms
71,400 KB
testcase_04 AC 73 ms
71,096 KB
testcase_05 AC 69 ms
71,392 KB
testcase_06 AC 73 ms
71,352 KB
testcase_07 AC 70 ms
71,284 KB
testcase_08 AC 73 ms
71,132 KB
testcase_09 AC 68 ms
71,284 KB
testcase_10 AC 73 ms
71,284 KB
testcase_11 AC 69 ms
71,140 KB
testcase_12 AC 73 ms
71,392 KB
testcase_13 AC 69 ms
71,192 KB
testcase_14 AC 74 ms
71,368 KB
testcase_15 AC 71 ms
71,384 KB
testcase_16 AC 74 ms
71,140 KB
testcase_17 AC 72 ms
71,172 KB
testcase_18 AC 75 ms
71,236 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

def exgcd(a, b):
    if b==0: return 1,0,a
    r = exgcd(b, a%b)
    return r[1],r[0]-a//b*r[1],r[2]

def crt(a0, m0, a1, m1):
    g = exgcd(m0,m1)[2]
    if a0%g!=a1%g: return -1,-1
    if g > 1:
        m0//=g
        m1//=g
        while True:
            h = exgcd(m0,g)[2]
            if h==1: break
            m0*=h
            g//=h
        m1 *= g
        a0 %= m0
        a1 %= m1
    r = exgcd(m0, m1)
    p,q,g=r[0],r[1],r[2]
    x = a0*q*m1+a1*p*m0
    m=m0*m1
    x%=m
    if x<0: x+=m
    return x,m

X=[]
Y=[]
for i in range(3):
    x, y = map(int, input().split())
    X.append(x)
    Y.append(y)

x, y = X[0], Y[0]
for i in range(1, 3):
    x, y = crt(x, y, X[i], Y[i])
if x==0: print(y)
else: print(x)
0