結果

問題 No.48 ロボットの操縦
コンテスト
ユーザー kai10920
提出日時 2023-01-25 18:33:26
言語 C++17
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 763 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 170 ms
コンパイル使用メモリ 38,784 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-06-29 09:39:01
合計ジャッジ時間 1,044 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 24 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include<stdio.h>

int walk(int to,int l){
    if(to%l==0){
        return to/l;
    }else{
        return to/l+1;
    }
}

int main(){
    int x;
    int y;
    int l;
    scanf("%d%d%d",&x,&y,&l);
    int step=0;
    if(y>0){
        step+=walk(y,l);
        
        if(x>0){
            step++;
            step+=walk(x,l);
        }else if(x<0){
            step++;
            step+=walk(-x,l);
        }
    }else if(y<0){
        step++;
        if(x>0){
            step+=walk(x,l);
        }else if(x<0){
            step+=walk(-x,l);
        }
        step++;
        step+=walk(-y,l);
    }else{
        step++;
        if(x>0){
            step+=walk(x,l);
        }else if(x<0){
            step+=walk(-x,l);
        }
    }
    printf("%d",step);
}
0