結果

問題 No.48 ロボットの操縦
ユーザー ococonomy1
提出日時 2018-09-07 16:54:13
言語 C
(gcc 13.3.0)
結果
AC  
実行時間 688 ms / 5,000 ms
コード長 603 bytes
コンパイル時間 410 ms
コンパイル使用メモリ 28,672 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-27 21:28:19
合計ジャッジ時間 2,112 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>

int main(void) {
  int x,y,l,count = 0,robX = 0,robY = 0;
  scanf("%d",&x); scanf("%d",&y); scanf("%d",&l);

  if(y >= 0){
    while(1){
      if(robY >= y)break;
      robY += l;
      count++;
    }
    if(x != 0)count++;
    if(x < 0)x *= -1;
    while(1){
      if(robX >= x)break;
      robX += l;
      count++;
    }
  }

  else{
    if(x < 0)x *= -1;
    count++;
    while(1){
      if(robX >= x)break;
      robX += l;
      count++;
    }
    count++;
    while(1){
      if(robY <= y)break;
      robY -= l;
      count++;
    }
  }

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