結果

問題 No.1544 [Cherry 2nd Tune C] Synchroscope
ユーザー otsunekootsuneko
提出日時 2021-06-11 22:03:21
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 453 ms / 2,000 ms
コード長 434 bytes
コンパイル時間 263 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 452,864 KB
最終ジャッジ日時 2024-05-08 17:48:04
合計ジャッジ時間 11,399 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
52,096 KB
testcase_01 AC 41 ms
52,224 KB
testcase_02 AC 38 ms
52,480 KB
testcase_03 AC 55 ms
74,368 KB
testcase_04 AC 104 ms
172,032 KB
testcase_05 AC 114 ms
201,940 KB
testcase_06 AC 143 ms
247,936 KB
testcase_07 AC 134 ms
240,512 KB
testcase_08 AC 105 ms
177,152 KB
testcase_09 AC 52 ms
72,192 KB
testcase_10 AC 132 ms
236,800 KB
testcase_11 AC 59 ms
86,400 KB
testcase_12 AC 70 ms
105,464 KB
testcase_13 AC 55 ms
74,624 KB
testcase_14 AC 190 ms
304,256 KB
testcase_15 AC 254 ms
348,032 KB
testcase_16 AC 92 ms
145,280 KB
testcase_17 AC 48 ms
62,336 KB
testcase_18 AC 52 ms
65,360 KB
testcase_19 AC 59 ms
80,768 KB
testcase_20 AC 189 ms
297,088 KB
testcase_21 AC 71 ms
103,552 KB
testcase_22 AC 55 ms
75,392 KB
testcase_23 AC 453 ms
452,608 KB
testcase_24 AC 444 ms
452,096 KB
testcase_25 AC 330 ms
452,736 KB
testcase_26 AC 337 ms
452,096 KB
testcase_27 AC 334 ms
452,608 KB
testcase_28 AC 329 ms
452,200 KB
testcase_29 AC 330 ms
452,608 KB
testcase_30 AC 328 ms
452,480 KB
testcase_31 AC 327 ms
452,720 KB
testcase_32 AC 329 ms
452,864 KB
testcase_33 AC 44 ms
60,416 KB
testcase_34 AC 39 ms
52,608 KB
testcase_35 AC 38 ms
52,480 KB
testcase_36 AC 45 ms
60,288 KB
testcase_37 AC 44 ms
59,520 KB
testcase_38 AC 330 ms
451,200 KB
testcase_39 AC 331 ms
451,328 KB
testcase_40 AC 328 ms
451,072 KB
testcase_41 AC 330 ms
451,584 KB
testcase_42 AC 322 ms
444,544 KB
testcase_43 AC 306 ms
428,544 KB
testcase_44 AC 312 ms
432,640 KB
testcase_45 AC 327 ms
446,080 KB
testcase_46 AC 315 ms
435,712 KB
testcase_47 AC 321 ms
440,184 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)

def lcm(a, b):
    return a * b // gcd (a, b)

N,M = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

l = lcm(N,M)

A2 = A*(l//N)
B2 = B*(l//M)
ans = 10**18
for i in range(l):
    if A2[i] == B2[i]:
        ans = min(ans,i+1)

if ans == 10**18:
    print(-1)
else:
    print(ans)
0