結果
問題 | No.240 ナイト散歩 |
ユーザー |
![]() |
提出日時 | 2015-07-10 22:29:46 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 1 ms / 2,000 ms |
コード長 | 437 bytes |
コンパイル時間 | 133 ms |
コンパイル使用メモリ | 23,168 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-07 20:47:38 |
合計ジャッジ時間 | 1,023 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:25:6: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 25 | scanf("%d %d",&X,&Y); | ~~~~~^~~~~~~~~~~~~~~
ソースコード
#include<stdio.h>int can(int nX,int nY,int step,int a,int b){if(nX==a && nY==b) return 1;if(step==0) return 0;int res=0;int dx[]={-2,-2,-1,-1,1,1,2,2};int dy[]={-1,1,-2,2,-2,2,-1,1};int i;for(i=0;i<8;i++){res|=can(nX+dx[i],nY+dy[i],step-1,a,b);if(res==1) break;}return res;}int main(void){int X,Y;scanf("%d %d",&X,&Y);int res=can(0,0,3,X,Y);if(res==1){printf("YES\n");} else {printf("NO\n");}return 0;}