結果
問題 | No.726 Tree Game |
ユーザー |
![]() |
提出日時 | 2018-08-24 23:57:46 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 670 bytes |
コンパイル時間 | 1,595 ms |
コンパイル使用メモリ | 167,496 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-23 11:27:24 |
合計ジャッジ時間 | 2,265 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 25 |
ソースコード
#include <bits/stdc++.h>using namespace std;#define ll long longll Y, X;bool isPrime(ll n) {if (n == 0 || n == 1) return false;for (ll i = 2; i*i <= n; i++) {if (n % i == 0) return false;}return true;}int main() {cin >> Y >> X;// 素数マスを求めるll up = Y, right = X;ll cnt = 0;while (!isPrime(X)) {up++;if (isPrime(up)) break;cnt++;}while (!isPrime(Y)) {right++;if (isPrime(right)) break;cnt++;}// マンハッタン距離が奇数なら初手側の勝ちif (cnt % 2) {puts("First");} else {puts("Second");}return 0;}