結果
問題 | No.726 Tree Game |
ユーザー |
![]() |
提出日時 | 2018-08-24 23:06:40 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 899 bytes |
コンパイル時間 | 1,504 ms |
コンパイル使用メモリ | 166,548 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-23 09:04:20 |
合計ジャッジ時間 | 2,366 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 13 WA * 12 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define REP(i,a,n) for(int i=(a); i<(int)(n); i++) #define rep(i,n) REP(i,0,n) #define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it) #define ALLOF(c) (c).begin(), (c).end() typedef long long ll; typedef unsigned long long ull; bool isPrime(ll n){ if(n<=1) return false; if(n==2) return true; if(n%2==0) return false; ll m=sqrt(n); for(ll i=3; i<=m; i+=2) if(n%i==0) return false; return true; } int main(){ ll Y, X; cin >> Y >> X; ll ret = 0; ll y = Y+1; while(!isPrime(y)) y++; ll x = X+1; while(!isPrime(x)) x++; y -= Y; x -= X; if(isPrime(Y) && isPrime(X)) ret = 0; else if(isPrime(Y+1) && isPrime(X+1)) ret = 0; else if(isPrime(Y)) ret = x; else if(isPrime(X)) ret = y; else ret = y+x+1; if(ret%2 == 0) cout << "Second" << endl; else cout << "First" << endl; return 0; }