結果

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

ソースコード

diff #

#include <iostream>
#include <cmath>

using namespace std;

int main(int argc, char const* argv[]) {
    int x[2], l, ans = 0;

    cin >> x[0] >> x[1] >> l;

    if (x[1] < 0) {
        ans += 2;
    } else if (x[0] != 0) {
        ans += 1;
    }

    for (int i = 0; i < 2; i++) {
        if (abs(x[i]) % l == 0) {
            ans += abs(x[i]) / l;
        } else {
            ans += abs(x[i]) / l + 1;
        }
    }

    cout << ans << endl;
    return 0;
}
0