結果
| 問題 |
No.726 Tree Game
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-08-30 12:03:57 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,246 bytes |
| コンパイル時間 | 456 ms |
| コンパイル使用メモリ | 23,680 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-09-13 19:49:01 |
| 合計ジャッジ時間 | 5,388 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 7 WA * 18 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:15:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
15 | scanf("%d %d",&Y,&X);
| ~~~~~^~~~~~~~~~~~~~~
ソースコード
#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");
}