結果

問題 No.48 ロボットの操縦
ユーザー hiyori
提出日時 2017-06-07 12:20:13
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 566 bytes
コンパイル時間 829 ms
コンパイル使用メモリ 63,308 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-09-22 12:42:32
合計ジャッジ時間 1,363 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 2 WA * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>

using namespace std;

int action (int n, int l, int flag)
{
    int sum = 0;
    if(n==0) { return 0; }
    if (flag) { sum++; }  //向きを変更する動作
    sum = n/l;
    if (n%l) { sum++; }
    return sum;
}


int main ()
{
    int x,y,l;
    cin >> x >> y >> l;
    
    int cnt = 0;
    if (y>0) {  // 北向きに移動するとき
        cnt += action(y,l,0);
        cnt += action(abs(x),l,1);
    }
    else {
        cnt += action(abs(x),l,1);
        cnt += action(abs(y),l,1);
    }
    cout << cnt << endl;
    return 0;
}


0