結果

問題 No.48 ロボットの操縦
ユーザー kai10920
提出日時 2023-01-25 18:29:41
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 698 bytes
コンパイル時間 504 ms
コンパイル使用メモリ 28,032 KB
最終ジャッジ日時 2025-02-10 06:46:57
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 2 WA * 23
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:15:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   15 |     scanf("%d%d%d",&x,&y,&l);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#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+=walk(x,l);
        }else if(x<0){
            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+=walk(-y,l);
    }else{
        step++;
        if(x>0){
            step+=walk(x,l);
        }else if(x<0){
            step+=walk(-x,l);
        }
    }
    printf("%d",step);
}
0