結果
問題 | No.726 Tree Game |
ユーザー |
![]() |
提出日時 | 2018-08-24 21:48:04 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 734 bytes |
コンパイル時間 | 779 ms |
コンパイル使用メモリ | 74,984 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-23 07:03:28 |
合計ジャッジ時間 | 1,483 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 25 |
ソースコード
#include <iostream> #include <vector> #include <string> #include <algorithm> #include <cstdio> #include <cstring> #include <cmath> using namespace std; using ll = long long; int is_prime(int n) { if (n < 2) return 0; int m = (int)sqrt(n); for (int i = 2; i <= m; i++) { if (n % i == 0) return 0; } return 1; } int next_prime(int n) { while (!is_prime(n)) n++; return n; } int foo() { int y, x; cin >> y >> x; if (is_prime(y) && is_prime(x)) { return 0; } if (y == 2 || x == 2) return 0; int i = next_prime(y + 1); int j = next_prime(x + 1); return (i - y + j - x) % 2; } int main() { cout << (foo() ? "First" : "Second") << endl; return 0; }