結果

問題 No.48 ロボットの操縦
ユーザー kachipan
提出日時 2023-06-23 14:27:49
言語 C
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 929 bytes
コンパイル時間 185 ms
コンパイル使用メモリ 30,464 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-06-30 19:10:29
合計ジャッジ時間 1,367 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 3 WA * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

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

// 座標を格納する構造体
struct pos
{
	int x;
	int y;
};

int main()
{
	struct pos robot = { 0,0 };
	int robotVec = 0;	// 向き0->北 1->東 2->南 3->西
	struct pos goal = { 0,0 };
	int move = 0;		// 進める距離
	int cnt = 0;
	int num = abs(goal.y);	// 絶対値を取得

	scanf("%d", &goal.y);
	scanf("%d", &goal.x);
	scanf("%d", &move);
	
	// 絶対値が0より大きければ0より小さくなるまでループ。ループした回数をカウントする
	while (num > 0)
	{
		num -= move;
		cnt++;
	}

	num = abs(goal.x);	// 絶対値を取得

	// 絶対値が0より大きければ0より小さくなるまでループ。ループした回数をカウントする
	while (num > 0)
	{
		num -= move;
		cnt++;
	}

	if (goal.y < 0)
	{
		cnt += 2;
	}
	else if (goal.x != 0)
	{
		cnt++;
	}

	printf("%d\n", cnt);

	return 0;
}

0