結果

問題 No.726 Tree Game
ユーザー weizenweizen
提出日時 2018-08-30 12:03:57
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,246 bytes
コンパイル時間 139 ms
コンパイル使用メモリ 27,352 KB
実行使用メモリ 4,484 KB
最終ジャッジ日時 2023-10-11 20:57:10
合計ジャッジ時間 5,738 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <stdio.h>

int dp[300][300];

int Y,X;
char isPrime(int a){
        if(a == 2) return 1;
        for(int k = 2; k*k <= a; k++)
                if(a%k==0) return 1;
        return 0;
}
int min(int a, int b){return (a<b)?a:b;}
int max(int a, int b){return (a>b)?a:b;}
int main(){
        scanf("%d %d",&Y,&X);

        for(int x = 0; x < 300; x++){
                for(int y = 0; y < 300; y++){
                        dp[x][y]=(isPrime(x+X)||isPrime(y+Y))?-1:100000;
                }
        }

        dp[0][0]=0;
        for(int x = 0; x < 300; x++){
                for(int y = 0; y < 300; y++){
                        if(dp[x][y] != -1){
                                int a = (dp[x-1][y]!=-1)?dp[x-1][y]:10000000;
                                int b = (dp[x][y-1]!=-1)?dp[x][y-1]:10000000;
                                dp[x][y] = min(a,b)+1;
                        }
                }
        }
        int cnt = 0;
        for(int x = 0; x < 300; x++){
                for(int y = 0; y < 300; y++){
                        if(dp[x][y] != -1 && dp[x][y] != 100000){
                                cnt = max(cnt,dp[x][y]);
                        }
                }
        }
        printf((cnt%2)?"First\n":"Second\n");
}
0