結果

問題 No.48 ロボットの操縦
ユーザー tenkyu9tenkyu9
提出日時 2017-11-20 02:37:37
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 906 bytes
コンパイル時間 1,027 ms
コンパイル使用メモリ 81,396 KB
実行使用メモリ 12,028 KB
最終ジャッジ日時 2023-08-17 06:38:04
合計ジャッジ時間 13,179 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
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 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include<random>
#include<ctime>
#include<cstdlib>
using namespace std;

int main(){

  long long int x, y, l, ans=0, move_x=0, move_y=0;
  cin >> x >> y >> l;

  if(x==0 && y==0){
    cout << 0 << endl;
    return 0;
  } else if(x!=0 && y>=0){
    ans++;
  } else if(x==0 && y<0){
    ans+=2;
  } else if(x!=0 && y<0){
    ans++;
  }

  while(1){
    if(x>0){
      move_x+=l;
      ans++;
      if(move_x>=x){
        break;
      }
    } else if(x<0){
      move_x-=l;
      ans++;
      if(move_x<=x){
        break;
      }
    }
  }

  while(1){
    if(y>0){
      move_y+=l;
      ans++;
      if(move_y>=y){
        break;
      }
    } else if(y<0){
      move_y-=l;
      ans++;
      if(move_y<=y){
        break;
      }
    }
  }

  cout << ans << endl;

  return 0;
}
0