結果

問題 No.186 中華風 (Easy)
ユーザー yaoshimaxyaoshimax
提出日時 2015-05-10 11:58:13
言語 Python2
(2.7.18)
結果
AC  
実行時間 366 ms / 2,000 ms
コード長 491 bytes
コンパイル時間 1,212 ms
コンパイル使用メモリ 6,644 KB
実行使用メモリ 37,840 KB
最終ジャッジ日時 2023-09-27 00:47:06
合計ジャッジ時間 6,344 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 179 ms
31,516 KB
testcase_01 AC 106 ms
26,652 KB
testcase_02 AC 86 ms
19,032 KB
testcase_03 AC 18 ms
10,548 KB
testcase_04 AC 181 ms
27,912 KB
testcase_05 AC 178 ms
31,468 KB
testcase_06 AC 242 ms
33,652 KB
testcase_07 AC 200 ms
33,064 KB
testcase_08 AC 308 ms
37,776 KB
testcase_09 AC 307 ms
37,648 KB
testcase_10 AC 252 ms
34,540 KB
testcase_11 AC 366 ms
37,840 KB
testcase_12 AC 119 ms
33,208 KB
testcase_13 AC 132 ms
24,736 KB
testcase_14 AC 143 ms
23,840 KB
testcase_15 AC 52 ms
27,636 KB
testcase_16 AC 149 ms
28,348 KB
testcase_17 AC 104 ms
29,904 KB
testcase_18 AC 83 ms
36,096 KB
testcase_19 AC 196 ms
37,444 KB
testcase_20 AC 70 ms
15,108 KB
testcase_21 AC 171 ms
32,952 KB
testcase_22 AC 192 ms
36,308 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def gcd(A,B):
    if B<A:
        return gcd(B,A)
    if B%A==0:
        return A
    return gcd(B%A,A)

X1,Y1=map(int,raw_input().split())
X2,Y2=map(int,raw_input().split())
X3,Y3=map(int,raw_input().split())

A1,B1=X1,Y1
if A1==0:
    A1+=Y1
for i in range(Y2):
    if A1%Y2==X2:
        break
    A1+=B1
if A1%Y2!=X2:
    print -1
    exit()
else:
    B1/=gcd(B1,Y2)
    B1*=Y2

for i in range(Y3):
    if A1%Y3==X3:
        break
    A1+=B1

if A1%Y3==X3:
    print A1
else:
    print -1
0