結果
問題 | No.240 ナイト散歩 |
ユーザー |
![]() |
提出日時 | 2017-01-09 15:37:33 |
言語 | C90 (gcc 12.3.0) |
結果 |
AC
|
実行時間 | 1 ms / 2,000 ms |
コード長 | 832 bytes |
コンパイル時間 | 318 ms |
コンパイル使用メモリ | 23,168 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-07 21:34:00 |
合計ジャッジ時間 | 1,318 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
コンパイルメッセージ
main.c: In function ‘main’: main.c:34:3: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 34 | scanf("%d %d",&X,&Y); | ^~~~~~~~~~~~~~~~~~~~
ソースコード
#include<stdio.h>#include<math.h>int X,Y;int make(int a,int b,int n){if(X==a && Y==b)return 1;if(n==3){if(X==a && Y==b)return 1;elsereturn 0;}else{if(make(a-2,b-1,n+1)==1)return 1;else if(make(a-2,b+1,n+1)==1)return 1;else if(make(a-1,b-2,n+1)==1)return 1;else if(make(a-1,b+2,n+1)==1)return 1;else if(make(a+1,b-2,n+1)==1)return 1;else if(make(a+1,b+2,n+1)==1)return 1;else if(make(a+2,b-1,n+1)==1)return 1;else if(make(a+2,b+1,n+1)==1)return 1;}return 0;}int main(void){int num,i;scanf("%d %d",&X,&Y);if((int)fabs(X)>7 || (int)fabs(Y)>7)puts("NO");else if(X==0 && Y==0)puts("YES");else if(make(0,0,0)==1)puts("YES");elseputs("NO");return 0;}