結果

問題 No.726 Tree Game
ユーザー hiro71687khiro71687k
提出日時 2023-04-11 12:41:41
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 1,703 bytes
コンパイル時間 4,369 ms
コンパイル使用メモリ 253,604 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-16 11:23:40
合計ジャッジ時間 5,210 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 3 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 3 ms
5,376 KB
testcase_20 AC 3 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 3 ms
5,376 KB
testcase_23 AC 2 ms
5,376 KB
testcase_24 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:90:9: warning: 'xx' may be used uninitialized [-Wmaybe-uninitialized]
   90 |         if (xx==x+1)
      |         ^~
main.cpp:45:11: note: 'xx' was declared here
   45 |     ll yy,xx;
      |           ^~
main.cpp:82:9: warning: 'yy' may be used uninitialized [-Wmaybe-uninitialized]
   82 |         if (yy==y+1)
      |         ^~
main.cpp:45:8: note: 'yy' was declared here
   45 |     ll yy,xx;
      |        ^~

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll=long long;
using ld=long double;
ld pie=3.141592653589793;
ll inf=144499999999994;
ll mod=998244353;
int main(){
    ll y,x;
    cin >> y >> x;
    bool o=true;
    for (ll i = 2; i*i <=y; i++)
    {
        if (y%i==0)
        {
            o=false;
            break;
        }
    }
    bool k=true;
    for (ll i = 2; i*i <=x; i++)
    {
        if (x%i==0)
        {
            k=false;
            break;
        }
    }
    if (y==1)
    {
        o=false;
    }
    if (x==1)
    {
        k=false;
    }
    
    if (o&&k)
    {
        cout << "Second" << endl;
        return 0;
    }
    ll yy,xx;
    for (ll i = y+1; i >=0; i++)
    {
        bool ok=false;
        for (ll j = 2; j*j <=i; j++)
        {
            if (i%j==0)
            {
                ok=true;
                break;
            }
        }
        if (!ok)
        {
            yy=i;
            break;
        }
    }
    for (ll i = x+1; i >=0; i++)
    {
        bool ok=false;
        for (ll j = 2; j*j <=i; j++)
        {
            if (i%j==0)
            {
                ok=true;
                break;
            }
        }
        if (!ok)
        {
            xx=i;
            break;
        }
    }
    if (o)
    {
        if (yy==y+1)
        {
            cout << "Second" << endl;
            return 0;
        }
    }
    if (k)
    {
        if (xx==x+1)
        {
            cout << "Second"<< endl;
            return 0;
        }
        
    }
    
    ll z=yy-y+xx-x-2;
    if (z%2)
    {
        cout << "First" << endl;
    }else{
        cout << "Second"<< endl;
    }
    
}
0