結果

問題 No.187 中華風 (Hard)
ユーザー tjaketjake
提出日時 2017-01-02 16:35:44
言語 Python2
(2.7.18)
結果
WA  
実行時間 -
コード長 426 bytes
コンパイル時間 1,662 ms
コンパイル使用メモリ 7,164 KB
実行使用メモリ 6,500 KB
最終ジャッジ日時 2023-08-22 07:53:55
合計ジャッジ時間 12,243 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 409 ms
6,352 KB
testcase_01 AC 402 ms
6,256 KB
testcase_02 AC 46 ms
6,432 KB
testcase_03 AC 45 ms
6,248 KB
testcase_04 AC 810 ms
6,500 KB
testcase_05 AC 809 ms
6,280 KB
testcase_06 AC 810 ms
6,424 KB
testcase_07 AC 805 ms
6,284 KB
testcase_08 AC 884 ms
6,428 KB
testcase_09 AC 887 ms
6,420 KB
testcase_10 AC 882 ms
6,288 KB
testcase_11 AC 814 ms
6,392 KB
testcase_12 AC 810 ms
6,480 KB
testcase_13 AC 16 ms
6,152 KB
testcase_14 AC 15 ms
6,212 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 11 ms
5,968 KB
testcase_18 AC 269 ms
6,308 KB
testcase_19 AC 11 ms
6,064 KB
testcase_20 AC 558 ms
6,332 KB
testcase_21 AC 11 ms
6,188 KB
testcase_22 AC 814 ms
6,384 KB
testcase_23 AC 11 ms
6,252 KB
testcase_24 AC 11 ms
6,112 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def extgcd(a, b):
    if b:
        d, y, x = extgcd(b, a%b)
        y -= (a/b)*x
        return d, x, y
    else:
        return a, 1, 0

n = input()
d = 1
x = 0
v = []
for i in xrange(n):
    X, Y = map(int, raw_input().split())
    g, a, b = extgcd(d, Y)
    x, d = (Y*b*x + d*a*X)/g, d*(Y / g)
    x = (x + d) % d
    v.append((X, Y))

for X, Y in v:
    if x % Y != X:
        print -1
        exit(0)
print x % (10**9+7)
0