結果

問題 No.726 Tree Game
ユーザー ilplrrilplrr
提出日時 2018-08-24 22:46:15
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 520 bytes
コンパイル時間 1,514 ms
コンパイル使用メモリ 143,668 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-05 12:48:59
合計ジャッジ時間 2,630 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

bool p(int a)
{
    if (a < 2) return 0;
    if (a == 2) return 1;

    //cerr << a << endl;
    for (int i = 2; i * i <= a; i++) {
        if (a % i == 0) return 0;
    }

    return 1;
}
int main()
{
    int y, x;
    cin >> y >> x;

    int a = x, b = y;
    if (p(a)) a++;
    if (p(b)) b++;

    for (; !p(a); a++);
    for (; !p(b); b++);

    int t = min (abs(a - x), abs(b - y)) + abs(a - b);
    
    cout << (t % 2 ? "Second" : "First") << endl;

    return 0;
}
0