結果

問題 No.48 ロボットの操縦
ユーザー tsukacchantsukacchan
提出日時 2016-03-25 20:42:24
言語 C90
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,365 bytes
コンパイル時間 414 ms
コンパイル使用メモリ 20,992 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-09 23:53:54
合計ジャッジ時間 1,356 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 1 ms
6,940 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 0 ms
6,940 KB
testcase_05 AC 1 ms
6,944 KB
testcase_06 AC 1 ms
6,940 KB
testcase_07 AC 0 ms
6,940 KB
testcase_08 WA -
testcase_09 AC 1 ms
6,940 KB
testcase_10 WA -
testcase_11 AC 1 ms
6,944 KB
testcase_12 AC 0 ms
6,940 KB
testcase_13 AC 0 ms
6,940 KB
testcase_14 AC 0 ms
6,940 KB
testcase_15 AC 0 ms
6,940 KB
testcase_16 AC 1 ms
6,940 KB
testcase_17 AC 0 ms
6,940 KB
testcase_18 WA -
testcase_19 AC 1 ms
6,948 KB
testcase_20 AC 0 ms
6,940 KB
testcase_21 AC 1 ms
6,940 KB
testcase_22 WA -
testcase_23 AC 0 ms
6,940 KB
testcase_24 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:10:1: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   10 | scanf("%d%d%d",&X,&Y,&L);
      | ^~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include<stdio.h>

int main(void){

//(X,Y) 移動させたい座標、L 一回の最大移動距離
//最初の座標は北向きで原点にある。
int X,Y,L;
int times=0,x_times=0, y_times=0;

scanf("%d%d%d",&X,&Y,&L);

if(X<0) X=(-1)*X;
if(Y<0) Y=(-1)*Y;

//軸の上4通り + 軸以外の象限内4通り= 8通り
if(X%L==0)
x_times=X/L;
if(X%L!=0)
x_times=X/L+1;
if(Y%L==0)
y_times=Y/L;
if(Y%L!=0)
y_times=Y/L+1;

if(X==0 && Y==0){
printf("0");
}
//X軸の正方向→方向転換1回
else if(X>0 && Y==0){
	times=x_times;
	times++;
	printf("%d",times);
}
//X軸の負方向→方向転換1回
else if(X<0 && Y==0){
	times=x_times;
	times++;
	printf("%d",times);
}
//Y軸の正方向→方向転換なし
else if(X==0 && Y>0){
	times=y_times;
	printf("%d",times);
}
//Y軸の負方向→方向転換2回
else if(X==0 && Y<0){
	times=y_times;
	times += 2;
	printf("%d",times);
}



//第1象限→方向転換1回
else if(X>0 && Y>0){
	times= x_times + y_times;
	times++;
	printf("%d",times);
}
//第2象限→方向転換1回
else if(X<0 && Y>0)	{
	times= x_times + y_times;
	times++;
	printf("%d",times);
}
//第3象限→方向転換2回
else if(X<0 && Y<0)	{
	times= x_times + y_times;
	times += 2;
	printf("%d",times);
}
//第4象限→方向転換2回
else if(X>0 && Y<0)	{
	times= x_times + y_times;
	times += 2;
	printf("%d",times);
}

return 0;

}
0