結果

問題 No.2811 Calculation Within Sequence
ユーザー Pres1dent
提出日時 2024-07-19 21:32:57
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 187 ms / 2,000 ms
コード長 495 bytes
コンパイル時間 2,051 ms
コンパイル使用メモリ 200,084 KB
最終ジャッジ日時 2025-02-23 16:24:14
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 41
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
  int n, m; cin >> n >> m;
  vector<int> a(n), b(m);
  int g = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    g = gcd(g, a[i]);
  }
  for (int i = 0; i < m; i++) { cin >> b[i]; }
  // cerr << g << endl;
  set<int> st;
  for (int i = 0; i < n; i++) {
    st.insert(a[i] % g);
  }
  for (int i = 0; i < m; i++) {
    if (not st.count(b[i] % g)) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}
0