結果

問題 No.726 Tree Game
ユーザー gazellegazelle
提出日時 2018-08-24 22:19:18
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 1,241 bytes
コンパイル時間 2,470 ms
コンパイル使用メモリ 214,616 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-05 12:12:12
合計ジャッジ時間 3,365 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define MOD 1000000007ll
#define INF 1000000000ll
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(ll)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back

map<P,ll> memo;
map<ll,ll> prime;

bool ok(ll x, ll y) {
	if(!prime.count(x)) {
		bool d=true;
		for(ll i=2; i*i<=x;i++) {
			if(x%i==0) {
				d=false;
				break;
			}
		}
		if(!d||x==1) prime[x]=false;
		else prime[x]=true;
	}
	if(!prime.count(y)) {
		bool d=true;
		for(ll i=2; i*i<=y;i++) {
			if(y%i==0) {
				d=false;
				break;
			}
		}
		if(!d||y==1) prime[y]=false;
		else prime[y]=true;
	}
	if(prime[x]||prime[y]) return false;
	else return true;
}

bool dfs(ll x, ll y) {
	if(memo.count(P(x,y))) return memo[P(x,y)];
	bool ret=false;
	if(ok(x+1,y)) ret=ret|!dfs(x+1,y);
	if(ok(x,y+1)) ret=ret|!dfs(x,y+1);
	return memo[P(x,y)]=ret;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll y,x;
	cin>>y>>x;
	if(dfs(x,y)) cout<<"First"<<endl;
	else cout<<"Second"<<endl;
}
0