結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 TLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:9:11: warning: format ‘%d’ expects argument of type ‘int*’, but argument 2 has type ‘long long int*’ [-Wformat=]
    9 |   scanf("%d %d %d", &X, &Y, &L);
      |          ~^         ~~
      |           |         |
      |           int*      long long int*
      |          %lld
main.cpp:9:14: warning: format ‘%d’ expects argument of type ‘int*’, but argument 3 has type ‘long long int*’ [-Wformat=]
    9 |   scanf("%d %d %d", &X, &Y, &L);
      |             ~^          ~~
      |              |          |
      |              int*       long long int*
      |             %lld
main.cpp:9:17: warning: format ‘%d’ expects argument of type ‘int*’, but argument 4 has type ‘long long int*’ [-Wformat=]
    9 |   scanf("%d %d %d", &X, &Y, &L);
      |                ~^           ~~
      |                 |           |
      |                 int*        long long int*
      |                %lld
main.cpp:60:13: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long long int’ [-Wformat=]
   60 |   printf ("%d\n", count);
      |            ~^     ~~~~~
      |             |     |
      |             int   long long int
      |            %lld
main.cpp:9:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    9 |   scanf("%d %d %d", &X, &Y, &L);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>
#define ll long long 
int main(void)
{
  ll X, Y, L;
  ll x = 0, y = 0;
  ll count = 0;
  
  scanf("%d %d %d", &X, &Y, &L);

  if(X > 0 && y >= 0){
	count = 1;
  }
  else if(X < 0 && Y >= 0){
	count = 1;
  }
  else if(X <= 0 && Y < 0){
	count = 2;
  }
  else if(X > 0 && Y < 0){
	count = 2;
  }
  
  
  for(; (X != x) || (Y != y); ++count){
	if(X > x){
	  if(X-x > L){
		x = x + L;
	  }
	  else {
		x = X;
	  }
	}
	else if(X < x){
	  if(x-X > L){
		x = x - L;
	  }
	  else {
		x = X;
	  }
	}
	else if(Y > y){
	  if(Y-y > L){
		y = y + L;
	  }
	  else {
		y = Y;
	  }
	}
	else if(Y < y){
	  if(y-Y > L){
		y = y - L;
	  }
	  else {
		y = Y;
	  }
	}
  }

  printf ("%d\n", count);
  
  return 0;
}
0