結果

問題 No.48 ロボットの操縦
ユーザー nyro2
提出日時 2017-12-05 16:09:14
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 755 ms / 5,000 ms
コード長 461 bytes
コンパイル時間 573 ms
コンパイル使用メモリ 54,844 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-11-28 16:40:03
合計ジャッジ時間 2,127 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>

int calcDistance(int dist, int stride) {
    int step = 0;
    if (dist<0) dist = -dist;
    
    while(step*stride < dist) {
        step += 1;
    }
    
    return step;
}

int main() {
    int X, Y, L;
    int step = 0;
    
    std::cin >> X >> Y >> L;
    
    if (Y < 0) step += 2;
    else if (X != 0) step += 1;
    
    step += calcDistance(X, L);
    step += calcDistance(Y, L);

    std::cout << step << std::endl;

	return 0;
}
0