結果

問題 No.1544 [Cherry 2nd Tune C] Synchroscope
ユーザー kokonotsu
提出日時 2021-07-19 16:52:27
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 230 ms / 2,000 ms
コード長 259 bytes
コンパイル時間 900 ms
コンパイル使用メモリ 82,272 KB
実行使用メモリ 454,472 KB
最終ジャッジ日時 2024-07-17 13:32:56
合計ジャッジ時間 7,950 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 48
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import gcd
N, M = map(int, input().split())

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

A = A*(M//g)
B = B*(N//g)

for i in range(len(A)):
    if A[i] == B[i]:
        print(i+1)
        exit(0)

print(-1)
0