結果

問題 No.1544 [Cherry 2nd Tune C] Synchroscope
ユーザー otsunekootsuneko
提出日時 2021-06-11 22:03:21
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 471 ms / 2,000 ms
コード長 434 bytes
コンパイル時間 1,313 ms
コンパイル使用メモリ 86,712 KB
実行使用メモリ 467,384 KB
最終ジャッジ日時 2023-08-21 12:29:20
合計ジャッジ時間 13,353 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,276 KB
testcase_01 AC 70 ms
71,272 KB
testcase_02 AC 70 ms
71,364 KB
testcase_03 AC 87 ms
89,812 KB
testcase_04 AC 150 ms
187,104 KB
testcase_05 AC 178 ms
216,480 KB
testcase_06 AC 240 ms
262,984 KB
testcase_07 AC 259 ms
255,972 KB
testcase_08 AC 153 ms
191,824 KB
testcase_09 AC 85 ms
88,468 KB
testcase_10 AC 205 ms
251,916 KB
testcase_11 AC 93 ms
102,716 KB
testcase_12 AC 101 ms
121,084 KB
testcase_13 AC 85 ms
90,288 KB
testcase_14 AC 302 ms
319,804 KB
testcase_15 AC 343 ms
362,512 KB
testcase_16 AC 188 ms
160,928 KB
testcase_17 AC 78 ms
78,420 KB
testcase_18 AC 79 ms
81,360 KB
testcase_19 AC 88 ms
96,380 KB
testcase_20 AC 263 ms
312,496 KB
testcase_21 AC 99 ms
118,812 KB
testcase_22 AC 84 ms
91,256 KB
testcase_23 AC 471 ms
466,744 KB
testcase_24 AC 460 ms
467,132 KB
testcase_25 AC 340 ms
467,200 KB
testcase_26 AC 344 ms
466,884 KB
testcase_27 AC 343 ms
467,384 KB
testcase_28 AC 339 ms
467,172 KB
testcase_29 AC 340 ms
467,064 KB
testcase_30 AC 340 ms
467,052 KB
testcase_31 AC 343 ms
467,176 KB
testcase_32 AC 351 ms
467,180 KB
testcase_33 AC 75 ms
75,812 KB
testcase_34 AC 70 ms
71,100 KB
testcase_35 AC 71 ms
71,308 KB
testcase_36 AC 75 ms
76,096 KB
testcase_37 AC 75 ms
75,936 KB
testcase_38 AC 338 ms
465,764 KB
testcase_39 AC 341 ms
466,040 KB
testcase_40 AC 338 ms
465,100 KB
testcase_41 AC 340 ms
466,076 KB
testcase_42 AC 334 ms
458,916 KB
testcase_43 AC 315 ms
443,200 KB
testcase_44 AC 321 ms
447,276 KB
testcase_45 AC 331 ms
460,200 KB
testcase_46 AC 327 ms
450,580 KB
testcase_47 AC 328 ms
454,916 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