結果

問題 No.48 ロボットの操縦
コンテスト
ユーザー カルロス
提出日時 2015-07-17 10:30:30
言語 C90
(gcc 12.4.0)
コンパイル:
gcc-12 -O2 -std=c90 -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
WA  
実行時間 -
コード長 954 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 142 ms
コンパイル使用メモリ 29,484 KB
最終ジャッジ日時 2026-02-23 18:48:09
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 23 WA * 2
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:6:5: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    6 |     scanf("%d %d %d", &X, &Y, &L);
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #
raw source code

#include <stdio.h>
#include <stdlib.h>

int main(void){
    int cnt = 0, X, Y, L;
    scanf("%d %d %d", &X, &Y, &L);

    if(Y>0){
        if(Y%L==0){
            cnt += Y/L;
        }else{
            cnt += Y/L + 1;
        }
        if(X!=0){
            cnt++;
            if(abs(X)%L==0){
                cnt += abs(X)/L;
            }else{
                cnt += abs(X)/L + 1;
            }
        }
    }else if(Y==0){
        if(X!=0){
            cnt++;
            if(X%L==0){
                cnt += X/L;
            }else{
                cnt += X/L + 1;
            }
        }
    }else{
        cnt++;
        if(abs(Y)%L==0){
            cnt += abs(Y)/L;
        }else{
            cnt += abs(Y)/L + 1;
        }
        if(X!=0){
            cnt++;
            if(abs(X)%L==0){
                cnt += abs(X)/L;
            }else{
                cnt += abs(X)/L + 1;
            }
        }
    }
    printf("%d\n", cnt);
    return 0;
}
0