結果

問題 No.48 ロボットの操縦
ユーザー Maeda
提出日時 2025-03-07 10:19:07
言語 C
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 639 bytes
コンパイル時間 638 ms
コンパイル使用メモリ 24,704 KB
実行使用メモリ 8,608 KB
最終ジャッジ日時 2025-03-07 10:19:11
合計ジャッジ時間 2,687 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other WA * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <stdbool.h>

void main(){
	//X座標
	int x = 0,y = 0,l = 0;
	int input = scanf("%d\n%d\n%d\n",&x,&y,&l);
	if(input == 2){
		printf("入力ミス\n");
	}
	printf("(%d,%d) 移動距離:%d\n",x,y,l);

	//命令回数
	int instructionCount = 0;
	//現在位置
	int trueX = 0 , trueY = 0;
	if( y < 0){
		instructionCount += 2;
		y *= -1;
	}else if(x != 0){
		instructionCount += 1;
		if(x < 0){
			x *= -1;
		}
	}

	while(x >= 0 || y >= 0){
		if(y >= 0){
			y -= l;
			instructionCount ++;
			continue;
		}
		if(x >= 0){
			x -= l;
			instructionCount ++;
			continue;
		}
	}
	printf("%d\n",instructionCount);
}
0