結果
| 問題 |
No.2811 Calculation Within Sequence
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-07-17 23:18:05 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 183 ms / 2,000 ms |
| コード長 | 741 bytes |
| コンパイル時間 | 1,732 ms |
| コンパイル使用メモリ | 199,100 KB |
| 最終ジャッジ日時 | 2025-02-23 16:06:22 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 41 |
ソースコード
#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
using ll = long long;
const ll mod = 998244353;
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define faster ios::sync_with_stdio(false);cin.tie(nullptr)
ll gcd(ll a,ll b){
if(a==0) return b;
return gcd(b%a,a);
}
int main() {
ll a,b;
cin >> a >> b;
vector<ll> t(a),s(b);
rep(i,a) cin >> t[i];
rep(i,b) cin >> s[i];
ll g=0;
rep(i,a) g=gcd(g,t[i]);
bool ok=true;
rep(i,b) if(s[i]%g!=0) ok=false;
if(ok){
cout << "Yes" << endl;
}else{
cout << "No" << endl;
}
return 0;
}