結果
問題 | No.1884 Sequence |
ユーザー |
|
提出日時 | 2022-03-25 21:41:16 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 56 ms / 2,000 ms |
コード長 | 886 bytes |
コンパイル時間 | 2,951 ms |
コンパイル使用メモリ | 252,340 KB |
実行使用メモリ | 5,476 KB |
最終ジャッジ日時 | 2024-10-14 05:37:55 |
合計ジャッジ時間 | 5,588 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 40 |
ソースコード
#include <bits/stdc++.h> #include <atcoder/modint> using namespace std; using Mint = atcoder::modint998244353; int main() { ios::sync_with_stdio(false); cin.tie(0); int N; cin >> N; vector<long long> V; for (int i = 0; i < N; ++i) { long long x; cin >> x; if (x != 0) V.push_back(x); } sort(V.begin(), V.end()); long long g = 0; bool eq = 0; for (int i = 0; i < (int)V.size() - 1; ++i) { g = gcd(g, V[i + 1] - V[i]); if (V[i] == V[i + 1]) eq = 1; } if (g == 0) { cout << "Yes" << endl; return 0; } if (eq) { cout << "No" << endl; return 0; } long long rng = V.back() - V.front(); long long cnt = rng / g + 1; if (cnt <= N) cout << "Yes" << endl; else cout << "No" << endl; }