結果

問題 No.48 ロボットの操縦
ユーザー hamray
提出日時 2017-11-17 18:23:30
言語 C++11
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,014 bytes
コンパイル時間 437 ms
コンパイル使用メモリ 59,300 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-25 08:51:29
合計ジャッジ時間 1,194 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int X, Y, L; cin >> X >> Y >> L;
    int cnt = 0;
        if(Y < 0 && X > 0){
            Y *= -1;
            cnt += 2;
            }else if(Y < 0 && X < 0){
                X *= -1;
                Y *= -1;
                cnt += 2;
                }else if(Y > 0 && X > 0){
                cnt++;
                }else if(Y > 0 && X < 0){
                X *= -1;
                cnt++;
                }else if(Y < 0 && X == 0 ){
                Y *= -1;
                cnt += 2;
                }else if(X < 0 && Y == 0){
                X *= -1;
                cnt++;
                }
            if(X % L != 0){
                cnt += X / L + 1;
            }else{
            cnt += X / L;
            }
            if(Y % L != 0){
                cnt += Y / L + 1;
            }else{
            cnt += Y / L;
            }
        cout << cnt << endl;
    return 0;
}
0