結果

問題 No.48 ロボットの操縦
ユーザー Maeda
提出日時 2025-03-11 16:04:34
言語 C
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 483 bytes
コンパイル時間 391 ms
コンパイル使用メモリ 24,576 KB
実行使用メモリ 7,328 KB
最終ジャッジ日時 2025-03-11 16:04:36
合計ジャッジ時間 1,938 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 3 WA * 22
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:5:5: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    5 |     scanf("%d\n%d\n%d",&y,&x,&l);
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>

void main(void){
    int x = 0 , y = 0 , l = 0;
    scanf("%d\n%d\n%d",&y,&x,&l);
    int turn = 0;
    if(y < 0){
        y *= -1;
        turn += 2;
    }else if(y >= 0 && x != 0){
        turn += 1;
    }else if(y >= 0 && x == 0){
        turn = 0;
    }
    int count = 0;
    while(y > 0){
        count++;
        y -= l;
    }
    turn += count-1;
    while(x > 0){
        count++;
        x -= l;
    }
    turn += count-1;
    
    printf("%d",turn);

}
0