結果

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

テストケース

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

ソースコード

diff #


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

int main(void){

  long int x,y,l;
  long int a=0,b=0;
  long int n=0;
  scanf("%ld",&x);
  scanf("%ld",&y);
  scanf("%ld",&l);
  long int xl = l;
  long 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("%ld\n",n);
  return 0;
}

0