結果
問題 | No.726 Tree Game |
ユーザー |
![]() |
提出日時 | 2018-08-24 22:19:18 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 29 ms / 2,000 ms |
コード長 | 1,241 bytes |
コンパイル時間 | 2,314 ms |
コンパイル使用メモリ | 208,176 KB |
最終ジャッジ日時 | 2025-01-06 12:35:24 |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 25 |
ソースコード
#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_backmap<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;}