結果

問題 No.48 ロボットの操縦
ユーザー kuisiba
提出日時 2016-03-27 15:04:08
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 851 bytes
コンパイル時間 454 ms
コンパイル使用メモリ 58,428 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-02 04:34:36
合計ジャッジ時間 1,277 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 24 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cmath>

using namespace std;

int walkCount(int a, int b) {
    if ((a % b) == 0) {
        return (static_cast<int>(abs(a)) / b);
    } else {
        return (static_cast<int>(abs(a)) / b + 1);
    }
}

int main() {
    int x, y, l;
    cin >> x >> y >> l;

    int ans = 0;

    if (y == 0) {
            if (x != 0) {
            ans = walkCount(x, l);
        }
    } else if (0 < y) {
        if (x == 0) {
            ans = walkCount(y, l);
        } else if (x != 0) {
            ans = walkCount(y, l) + walkCount(x, l);
            ans++;
        }
    } else if (y < 0) {
        if (x == 0) {
            ans = walkCount(y, l);
            ans += 2;
        } else if (x != 0) {
            ans = walkCount(y, l) + walkCount(x, l);
            ans += 2;
        }
    }
    cout << ans <<endl;
    return 0;
}
0