結果

問題 No.48 ロボットの操縦
ユーザー sk3388607083
提出日時 2018-06-21 16:09:29
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 387 bytes
コンパイル時間 103 ms
コンパイル使用メモリ 22,656 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-06-30 17:36:28
合計ジャッジ時間 820 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 19 WA * 6
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:7:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    7 |   scanf("%ld", &X);
      |   ~~~~~^~~~~~~~~~~
main.cpp:8:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    8 |   scanf("%ld", &Y);
      |   ~~~~~^~~~~~~~~~~
main.cpp:9:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    9 |   scanf("%ld", &L);
      |   ~~~~~^~~~~~~~~~~

ソースコード

diff #

#include<stdio.h>

int main(void){
  long int X, Y, L;
  long int order = 0;

  scanf("%ld", &X);
  scanf("%ld", &Y);
  scanf("%ld", &L);

  if(X != 0) order += 1;
  if(Y < 0) order += 2;
  if(X < 0) X = -1 * X;
  if(Y < 0) Y = -1 * Y;
  if(X % L) order += X / L + 1;
  else order += X / L;
  if(Y % L) order += Y / L + 1;
  else order += Y / L;
  printf("%ld\n", order); 
  return 0;
}
0