結果

問題 No.187 中華風 (Hard)
ユーザー snukesnuke
提出日時 2015-04-20 16:09:34
言語 Python2
(2.7.18)
結果
WA  
実行時間 -
コード長 325 bytes
コンパイル時間 69 ms
コンパイル使用メモリ 6,624 KB
実行使用メモリ 6,228 KB
最終ジャッジ日時 2023-09-18 01:11:24
合計ジャッジ時間 11,750 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 44 ms
5,996 KB
testcase_03 AC 43 ms
6,056 KB
testcase_04 AC 796 ms
6,064 KB
testcase_05 AC 797 ms
6,112 KB
testcase_06 AC 800 ms
6,140 KB
testcase_07 AC 798 ms
6,140 KB
testcase_08 AC 874 ms
6,064 KB
testcase_09 AC 870 ms
6,212 KB
testcase_10 AC 871 ms
6,228 KB
testcase_11 AC 800 ms
6,136 KB
testcase_12 AC 802 ms
6,056 KB
testcase_13 AC 15 ms
5,836 KB
testcase_14 AC 16 ms
5,912 KB
testcase_15 AC 38 ms
5,908 KB
testcase_16 AC 39 ms
5,920 KB
testcase_17 AC 12 ms
5,840 KB
testcase_18 WA -
testcase_19 AC 12 ms
5,860 KB
testcase_20 AC 545 ms
6,080 KB
testcase_21 AC 11 ms
5,916 KB
testcase_22 AC 797 ms
6,092 KB
testcase_23 AC 11 ms
5,988 KB
testcase_24 AC 11 ms
5,980 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(raw_input())

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

def fail():
  print -1
  exit(0)

a = 0
b = 1
for i in xrange(n):
  na,nb = map(int,raw_input().split())
  g,x,y = extgcd(b,nb)
  l = b/g*nb
  a,b = ((a+(na-a)/g*x*b)%l,l)

if a == 0: a = b
print a%1000000007
0