結果

問題 No.48 ロボットの操縦
ユーザー sukesan_828sukesan_828
提出日時 2016-05-30 20:19:25
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 485 bytes
コンパイル時間 143 ms
コンパイル使用メモリ 24,320 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-16 18:47:13
合計ジャッジ時間 5,572 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
6,812 KB
testcase_01 AC 0 ms
6,940 KB
testcase_02 AC 0 ms
6,944 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 0 ms
6,940 KB
testcase_06 AC 1 ms
6,940 KB
testcase_07 AC 1 ms
6,944 KB
testcase_08 AC 1 ms
6,940 KB
testcase_09 AC 1 ms
6,940 KB
testcase_10 WA -
testcase_11 AC 0 ms
6,940 KB
testcase_12 WA -
testcase_13 AC 0 ms
6,944 KB
testcase_14 WA -
testcase_15 AC 1 ms
6,944 KB
testcase_16 AC 1 ms
6,940 KB
testcase_17 AC 0 ms
6,940 KB
testcase_18 WA -
testcase_19 AC 0 ms
6,940 KB
testcase_20 AC 1 ms
6,940 KB
testcase_21 AC 1 ms
6,940 KB
testcase_22 AC 0 ms
6,940 KB
testcase_23 AC 1 ms
6,940 KB
testcase_24 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:9:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    9 |   scanf("%d",&x);
      |   ~~~~~^~~~~~~~~
main.cpp:10:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   10 |   scanf("%d",&y);
      |   ~~~~~^~~~~~~~~
main.cpp:11:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   11 |   scanf("%d",&l);
      |   ~~~~~^~~~~~~~~

ソースコード

diff #

#include<stdio.h>
#include<stdlib.h>

int main(void){

  int x,y,l;
  int a=0,b=0;
  int n=0;
  scanf("%d",&x);
  scanf("%d",&y);
  scanf("%d",&l);
  int xl = l;
  int yl = l;
  while(a != x || b != y){
    if(x < 0 && xl > 0){
      xl *= -1;
    }
    else if( a != x){
      a += (abs(x-a)<l)?(x-a):xl;
    }

    else if(y < 0 && yl > 0){
      n++;
      yl *= -1;
    }
    else if(b != y){
      b += (abs(y-b)<l)?(y-b):yl;
    }
    n++;
  }
  printf("%d\n",n);
  return 0;
}

0