結果

問題 No.726 Tree Game
コンテスト
ユーザー Khiromu
提出日時 2018-08-24 21:53:13
言語 C++14
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 844 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 861 ms
コンパイル使用メモリ 184,496 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2026-03-07 22:50:55
合計ジャッジ時間 1,407 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 19 WA * 6
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;

ll y, x;
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2) {
        if (num % i == 0) {
            return false;
        }
    }

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

    ll ans=0;
    if(IsPrime(y) || IsPrime(x)){
        cout<<"First"<<endl;
        return 0;
    }

    while(!IsPrime(y)){
        ans++;
        y++;
    }
    while(!IsPrime(x)){
        ans++;
        x++;
    }

    if((ans-2)%2==0) cout<<"Second"<<endl;
    else cout<<"First"<<endl;
    return 0;
}
0