結果

問題 No.240 ナイト散歩
コンテスト
ユーザー takatowin
提出日時 2017-01-09 15:37:33
言語 C90(gcc15)
(gcc 15.2.0)
コンパイル:
gcc-15 -O2 -std=c90 -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 832 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 178 ms
コンパイル使用メモリ 39,288 KB
最終ジャッジ日時 2026-02-24 00:04:47
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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;
    else
      return 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");
  else
    puts("NO");
  return 0;
}

0