結果

問題 No.2811 Calculation Within Sequence
ユーザー Butterflv
提出日時 2024-07-19 21:56:08
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 209 ms / 2,000 ms
コード長 445 bytes
コンパイル時間 311 ms
コンパイル使用メモリ 81,920 KB
実行使用メモリ 163,196 KB
最終ジャッジ日時 2024-07-19 21:56:22
合計ジャッジ時間 7,919 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 41
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import*
a,b=map(int,input().split())
T=list(map(int,input().split()))
S=list(map(int,input().split()))

T_gcd=None

if a==1: T_gcd=T[0]
else: T_gcd=gcd(T[0], T[1])

for i in range(1, len(T)): T_gcd=gcd(T_gcd, T[i])

T_mod_set=set()
S_mod_set=set()

for elm in T:
  T_mod_set.add(elm%T_gcd)

for elm in S:
  S_mod_set.add(elm%T_gcd)

flag=True

for elm in S_mod_set:
  if elm not in T_mod_set:
    flag=False

print(["No","Yes"][flag])
0