結果

問題 No.726 Tree Game
ユーザー tetsutetsu
提出日時 2018-08-24 23:05:25
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,051 bytes
コンパイル時間 1,741 ms
コンパイル使用メモリ 165,200 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-09-05 13:24:20
合計ジャッジ時間 2,515 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)

ll get(ll x) {
  ll p = x+1;
  for(;;p++) {
    bool f = true;
    for(ll k=2; k*k<=p; k++) {
      if(p%k==0) {
	f = false;
	break;
      }
    }
    if(f)
      break;
  }
  return p;
}

int main() {
  ll x,y;
  cin>>x>>y;
  bool f1=true,f2=true;
  for(ll k=2; k*k<=x; k++) {
    if(x%k==0) {
      f1 = false;
      break;
    }
  }
  for(ll k=2; k*k<=y; k++) {
    if(y%k==0) {
      f2 = false;
      break;
    }
  }
  if(f1&&f2) {
    cout << "Second" << endl;
    return 0;
  }
  if(f1&&!f2) {
    ll p=get(x);
    if((x-p)%2==0) {
      cout << "First" << endl;
    } else {
      cout << "Second" << endl;
    }
    return 0;
  }
  if(!f1&&f2) {
    ll p=get(y);
    if((y-p)%2==0) {
      cout << "First" << endl;
    } else {
      cout << "Second" << endl;
    }
    return 0;
  }
  ll p=get(x);
  ll q=get(y);
  if(((x-p)+(y-q))%2==0) {
    cout << "Second"<<endl;
  } else {
    cout << "First" << endl;
  }
  return 0;
}
0