結果

問題 No.48 ロボットの操縦
ユーザー jolly_gliscor
提出日時 2018-03-19 08:26:47
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 581 bytes
コンパイル時間 665 ms
コンパイル使用メモリ 62,172 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-12-31 10:33:37
合計ジャッジ時間 1,683 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <cmath>

using std::cout;
using std::cin;
using std::endl;

void conutInstruction(int a, int b, int c)
{
  int count;
  if ( a == 0 && b >= 0 )
    count = 0;
  else
    count = 1;
  
  // move to x axis direction
  count += fabs(b / c);
  if ( b % c !=0 )
    count++;
  //move to y axis direction
  count += fabs(a / c);
  if ( a % c != 0 )
    count++;
  //think the signature
  if ( b < 0 )
    count++;
  
  cout << count << endl;
}

int main(void)
{
  int x,y,z;
  cin >> x >> y >> z;
  conutInstruction(x, y, z);
  return 0;
}
0