結果

問題 No.1544 [Cherry 2nd Tune C] Synchroscope
ユーザー norioc
提出日時 2025-05-13 21:04:56
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 138 ms / 2,000 ms
コード長 231 bytes
コンパイル時間 680 ms
コンパイル使用メモリ 82,324 KB
実行使用メモリ 63,088 KB
最終ジャッジ日時 2025-05-13 21:05:02
合計ジャッジ時間 5,326 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 48
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import lcm

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

t = lcm(N, M)
for i in range(t):
    if A[i%N] == B[i%M]:
        print(i+1)
        exit()

print(-1)
0