結果

問題 No.726 Tree Game
ユーザー firiexp
提出日時 2018-08-24 22:08:32
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 836 bytes
コンパイル時間 612 ms
コンパイル使用メモリ 79,096 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-23 07:34:44
合計ジャッジ時間 1,285 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>

static const int INF = 1000000007;
using ll = long long;
using namespace std;

bool is_prime(long long n) {
    if (n < 2) return false;
    for (long long i = 2; i * i <= n; ++i) {
        if (n % i == 0) return false;
    }
    return true;
}

int main() {
    int y, x, yy, xx;
    cin >> y >> x;
    if(x == 2 || y == 2) {
        cout << "Second" << "\n";
        return 0;
    }
    for (int i = x+1;; ++i) {
        if (is_prime(i)) {
            xx = i;
            break;
        }
    }
    for (int i = y+1;; ++i) {
        if (is_prime(i)) {
            yy = i;
            break;
        }
    }
    int dis = (yy - y - 1) + (xx - x - 1);
    if(dis%2) cout << "First" << "\n";
    else cout << "Second" << "\n";
    return 0;
}
0