結果

問題 No.48 ロボットの操縦
ユーザー hiyori
提出日時 2016-10-14 20:03:54
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 652 bytes
コンパイル時間 445 ms
コンパイル使用メモリ 55,588 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-11-22 06:50:24
合計ジャッジ時間 1,278 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 4 WA * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>

using namespace std;

int action (int num, int l)
{
  int count = 0;

  if (num >= l) {
    count += num/l;
    num = num % l;
  }
  count += num;

  return count;
}

int main ()
{
  int x, y, l;
  cin >> x >> y >> l;
  int count = 0;  // 行動をカウントする

  if (x < 0) x *= -1;

  if (y < 0) {
    if (x > 0) {
      count++;
      count += action(x, l);
    }

    y *= -1;
    if (y > 0) {
      count++;
      count += action(y, l);
    }
  }
  else {
    if (x > 0) {
      count++;
      count += action(x, l);
    }

    if (y > 0) {
      count += action(y, l);
    }
  }

  cout << count << endl;
  return 0;
}
0