結果

問題 No.2811 Calculation Within Sequence
ユーザー kotatsugame
提出日時 2024-07-19 21:21:47
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 56 ms / 2,000 ms
コード長 446 bytes
コンパイル時間 563 ms
コンパイル使用メモリ 62,976 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-19 21:21:52
合計ジャッジ時間 4,213 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 41
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<cassert>
using namespace std;
long long gcd(long long a,long long b)
{
	while(b)
	{
		long long t=a%b;
		a=b;
		b=t;
	}
	return a;
}
int N,M;
int T[2<<17],S[2<<17];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cin>>N>>M;
	int g=0;
	for(int i=0;i<N;i++)
	{
		cin>>T[i];
		g=gcd(g,T[i]);
	}
	bool fn=false;
	for(int i=0;i<M;i++)
	{
		cin>>S[i];
		if(S[i]%g!=0)fn=true;
	}
	cout<<(fn?"No\n":"Yes\n");
}
0