結果

問題 No.726 Tree Game
ユーザー spihillspihill
提出日時 2018-08-24 22:03:18
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,710 bytes
コンパイル時間 2,454 ms
コンパイル使用メモリ 166,640 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-05 11:48:40
合計ジャッジ時間 2,631 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

void init();
void solve();

#define rep(i, a) for (int i = 0; i < (int) (a); i++)
#define reps(i, a, b) for (int i = (int) (a); i < (int) (b); i++)
#define rrep(i, a) for (int i = (int) a-1; i >= 0; i--)
#define rreps(i, a, b) for (int i = (int) (a)-1; i >= (int) (b); i--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define TRUE__ "Yes"
#define FALSE__ "No"
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x

#ifdef LOCAL
#define lcout(a) cout << a;
#define lcoutln(a) cout << a << endl;
#define lcerr(a) cerr << a;
#define lcerrln(a) cerr << a << endl;
#else
#define lcout(a) 
#define lcoutln(a) 
#define lcerr(a) 
#define lcerrln(a) 
#endif
#define MOD 1000000007

ll R, C;
vector<ll> sosu;

signed main()
{
	init();
	solve();
}

inline bool isprime(ll x)
{
	if (x == 1) return false;
	if (x == 2) return true;
	if (x % 2 == 0) return false;
	for (ll i = 3; i * i <= x; i += 2) {
		if (x % i == 0) return false;
	}
	return true;
}

void init()
{
	cin >> R >> C;
}

ll ne(ll x)
{
	x++;
	while (!isprime(x)) {
		x+=1;
	}
	return x;
}

void solve()
{
	ll cnt = 0;
	if (R == 2 || C == 2) {
		cout << "Second" << endl;
		return;
	}
	if (isprime(R)) {
		if (isprime(C)) {
			cout << "Second" << endl;
			return;
		}
		R++;
		cnt++;
	} else if (isprime(C)) {
		C++;
		cnt++;
	}
	cnt += ne(R) - R;
	cnt += ne(C) - C;
	if (cnt % 2 == 0) {
		cout << "Second" << endl;
	} else {
		cout << "First" << endl;
	}
}
0