結果
問題 | No.726 Tree Game |
ユーザー | ldsyb |
提出日時 | 2018-08-25 22:21:26 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 727 bytes |
コンパイル時間 | 1,491 ms |
コンパイル使用メモリ | 168,828 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-27 00:16:32 |
合計ジャッジ時間 | 2,365 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 25 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { auto is_prime = [](int64_t n) { if (n < 2) { return false; } if (n == 2) { return true; } for (int64_t i = 2; i * i <= n; i++) { if (n % i == 0) { return false; } } return true; }; int64_t x, y; cin >> x >> y; if ((x == 2) || (y == 2)) { cout << "Second" << endl; return 0; } if (is_prime(x) && is_prime(y)) { cout << "Second" << endl; return 0; } int64_t xp = x + 1, yp = y + 1; while (!is_prime(xp)) { xp++; } while (!is_prime(yp)) { yp++; } if ((xp == x) || (yp == y)) { cout << "First" << endl; return 0; } cout << ((((xp - x) + (yp - y)) % 2) ? "First" : "Second") << endl; return 0; }