結果
| 問題 | 
                            No.2811 Calculation Within Sequence
                             | 
                    
| コンテスト | |
| ユーザー | 
                             Pres1dent
                         | 
                    
| 提出日時 | 2024-07-19 21:31:36 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                MLE
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 495 bytes | 
| コンパイル時間 | 1,884 ms | 
| コンパイル使用メモリ | 194,996 KB | 
| 最終ジャッジ日時 | 2025-02-23 16:22:42 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 14 MLE * 1 -- * 26 | 
ソースコード
#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;
  vector<int> ok(g);
  for (int i = 0; i < n; i++) {
    ok[a[i] % g] = true;
  }
  for (int i = 0; i < m; i++) {
    if (not ok[b[i] % g]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}
            
            
            
        
            
Pres1dent