結果

問題 No.48 ロボットの操縦
ユーザー tenkyu9tenkyu9
提出日時 2017-11-20 02:36:03
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 806 bytes
コンパイル時間 745 ms
コンパイル使用メモリ 82,404 KB
実行使用メモリ 8,752 KB
最終ジャッジ日時 2023-08-17 06:35:34
合計ジャッジ時間 7,279 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 TLE -
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++;
    } else if(x<0){
      move_x-=l;
      ans++;
    }
    if(move_x>=x){
      break;
    }
  }

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

  cout << ans << endl;

  return 0;
}
0