結果

問題 No.186 中華風 (Easy)
ユーザー yaoshimaxyaoshimax
提出日時 2015-05-10 11:56:12
言語 Python2
(2.7.18)
結果
WA  
実行時間 -
コード長 472 bytes
コンパイル時間 187 ms
コンパイル使用メモリ 6,664 KB
実行使用メモリ 37,880 KB
最終ジャッジ日時 2023-09-19 09:40:04
合計ジャッジ時間 5,855 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 111 ms
26,748 KB
testcase_02 AC 91 ms
19,092 KB
testcase_03 AC 19 ms
10,536 KB
testcase_04 AC 193 ms
27,976 KB
testcase_05 AC 189 ms
31,520 KB
testcase_06 AC 258 ms
33,636 KB
testcase_07 AC 211 ms
33,096 KB
testcase_08 AC 323 ms
37,748 KB
testcase_09 AC 316 ms
37,880 KB
testcase_10 WA -
testcase_11 AC 380 ms
37,808 KB
testcase_12 AC 123 ms
33,216 KB
testcase_13 AC 137 ms
24,580 KB
testcase_14 AC 149 ms
23,968 KB
testcase_15 AC 59 ms
27,604 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 90 ms
36,284 KB
testcase_19 AC 208 ms
37,572 KB
testcase_20 AC 72 ms
15,256 KB
testcase_21 AC 179 ms
32,960 KB
testcase_22 AC 200 ms
36,460 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
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 -2

0