結果

問題 No.726 Tree Game
ユーザー ei1333333ei1333333
提出日時 2018-08-24 22:29:59
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 524 bytes
コンパイル時間 1,971 ms
コンパイル使用メモリ 198,380 KB
実行使用メモリ 7,484 KB
最終ジャッジ日時 2023-09-05 12:27:43
合計ジャッジ時間 6,049 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 13 ms
4,376 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 20 ms
4,380 KB
testcase_20 AC 12 ms
4,384 KB
testcase_21 TLE -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

using int64 = long long;

bool prime(int i) {
  if(i == 1) return false;
  for(int j = 2; j * j <= i; j++) {
    if(i % j == 0) return false;
  }
  return true;
}

bool check(int Y, int X) {
  bool f = false;
  if(!prime(Y + 1) && !prime(X)) f |= !check(Y + 1, X);
  if(f) return true;
  if(!prime(Y) && !prime(X + 1)) f |= !check(Y, X + 1);
  return f;
}

int main() {
  int Y, X;
  cin >> Y >> X;
  if(check(Y, X)) cout << "First" << endl;
  else cout << "Second" << endl;
}
0