結果

問題 No.48 ロボットの操縦
ユーザー mell1
提出日時 2018-11-22 19:49:04
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 418 bytes
コンパイル時間 446 ms
コンパイル使用メモリ 53,976 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-24 17:46:02
合計ジャッジ時間 1,252 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;
int main() {
    int x, y, stp, a, b, count = 0;
    cin >> x >> y >> stp;
    
    if (x != 0) {
        if (y >= 0) count++;
        else count += 2;
    } else {
        if (y < 0) count += 2;
    }
    
    a = abs(x) / stp;
    if (x % stp != 0) a++;
    b = abs(y) / stp;
    if (y % stp != 0) b++;
    
    count += a + b;
    
    cout << count << endl;
    return 0;
}
0