結果

問題 No.48 ロボットの操縦
コンテスト
ユーザー mono1977
提出日時 2016-12-04 02:10:51
言語 C11(gcc12 gnu拡張)
(gcc 12.4.0)
コンパイル:
gcc-12 -O2 -std=gnu11 -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
AC  
実行時間 0 ms / 5,000 ms
+ 709µs
コード長 351 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 137 ms
コンパイル使用メモリ 31,744 KB
実行使用メモリ 5,888 KB
最終ジャッジ日時 2026-07-28 01:31:25
合計ジャッジ時間 1,591 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 25
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:17:35: warning: implicit declaration of function ‘abs’ [-Wimplicit-function-declaration]
   17 |         inst += (int)ceil((double)abs(x)/(double)l);
      |                                   ^~~
main.c:3:1: note: include ‘<stdlib.h>’ or provide a declaration of ‘abs’
    2 | #include<math.h>
  +++ |+#include <stdlib.h>
    3 | 
main.c:7:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    7 |         scanf("%d%d%d",&x,&y,&l);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #
raw source code

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

int main(){
	int x,y,l;
	int inst;
	scanf("%d%d%d",&x,&y,&l);
	
	if(y<0){
		inst=2;//y+ -> x+ or x- -> y-
	}else if(y>=0 && x==0){
		inst=0;//y+
	}else{
		inst=1;//y+ -> x+ or x-
	}
	
	inst += (int)ceil((double)abs(x)/(double)l);
	inst += (int)ceil((double)abs(y)/(double)l);
		
	printf("%d\n",inst);
	
	return 0;
}
0