結果
| 問題 |
No.726 Tree Game
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-08-24 22:15:36 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 984 bytes |
| コンパイル時間 | 2,147 ms |
| コンパイル使用メモリ | 197,392 KB |
| 最終ジャッジ日時 | 2025-01-06 12:35:13 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 23 WA * 2 |
ソースコード
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
vector<int> list_primes(int n) {
vector<bool> is_prime(n, true);
is_prime[0] = is_prime[1] = false;
for (int i = 2; i *(ll) i < n; ++ i)
if (is_prime[i])
for (int k = 2 * i; k < n; k += i)
is_prime[k] = false;
vector<int> primes;
for (int i = 2; i < n; ++ i)
if (is_prime[i])
primes.push_back(i);
return primes;
}
bool is_prime(ll n, vector<int> const & primes) {
for (int p : primes) {
if (n < (ll)p * p) break;
if (n % p == 0) return false;
}
return true;
}
bool solve(int y, int x) {
const auto primes = list_primes(1e5);
int h = 0;
int w = 0;
while (not is_prime(y + h + 1, primes)) ++ h;
while (not is_prime(x + w + 1, primes)) ++ w;
return (h % 2) ^ (w % 2);
}
int main() {
int y, x; cin >> y >> x;
cout << (solve(y, x) ? "First" : "Second") << endl;
return 0;
}