結果

問題 No.281 門松と魔法(1)
ユーザー NTstuNTstu
提出日時 2016-06-14 18:40:19
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 900 bytes
コンパイル時間 236 ms
コンパイル使用メモリ 31,104 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-11-06 19:54:13
合計ジャッジ時間 1,549 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1 ms
6,816 KB
testcase_02 WA -
testcase_03 AC 1 ms
6,816 KB
testcase_04 AC 1 ms
6,816 KB
testcase_05 AC 1 ms
6,816 KB
testcase_06 WA -
testcase_07 AC 1 ms
6,820 KB
testcase_08 AC 0 ms
6,820 KB
testcase_09 AC 0 ms
6,816 KB
testcase_10 AC 1 ms
6,820 KB
testcase_11 AC 1 ms
6,816 KB
testcase_12 AC 1 ms
6,816 KB
testcase_13 AC 1 ms
6,820 KB
testcase_14 AC 1 ms
6,816 KB
testcase_15 WA -
testcase_16 AC 1 ms
6,816 KB
testcase_17 WA -
testcase_18 AC 1 ms
6,820 KB
testcase_19 WA -
testcase_20 AC 1 ms
6,816 KB
testcase_21 AC 1 ms
6,820 KB
testcase_22 AC 1 ms
6,820 KB
testcase_23 WA -
testcase_24 AC 1 ms
6,820 KB
testcase_25 WA -
testcase_26 AC 1 ms
6,820 KB
testcase_27 AC 1 ms
6,820 KB
testcase_28 AC 0 ms
6,816 KB
testcase_29 AC 1 ms
6,820 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 1 ms
6,816 KB
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 0 ms
6,816 KB
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 AC 0 ms
6,820 KB
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
testcase_52 WA -
testcase_53 WA -
testcase_54 WA -
testcase_55 AC 0 ms
6,820 KB
testcase_56 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:16:13: warning: ‘char* gets(char*)’ is deprecated [-Wdeprecated-declarations]
   16 |         gets(str);
      |         ~~~~^~~~~
In file included from /usr/include/stdio.h:894,
                 from main.cpp:1:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:240:1: note: declared here
  240 | gets (char *__str)
      | ^~~~
main.cpp:18:13: warning: ‘char* gets(char*)’ is deprecated [-Wdeprecated-declarations]
   18 |         gets(str);
      |         ~~~~^~~~~
In file included from /usr/include/stdio.h:894,
                 from main.cpp:1:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:240:1: note: declared here
  240 | gets (char *__str)
      | ^~~~
main.cpp:20:13: warning: ‘char* gets(char*)’ is deprecated [-Wdeprecated-declarations]
   20 |         gets(str);
      |         ~~~~^~~~~
In file included from /usr/include/stdio.h:894,
                 from main.cpp:1:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:240:1: note: declared here
  240 | gets (char *__str)
      | ^~~~
main.cpp:22:13: warning: ‘char* gets(char*)’ is deprecated [-Wdeprecated-declarations]
   22 |         gets(str);
      |         ~~~~^~~~~
In file included from /usr/include/stdio.h:894,
                 from main.cpp:1:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:240:1: note: declared here
  240 | gets (char *__str)
      | ^~~~
main.cpp:16:13: warning: ignoring return value of ‘char* gets(char*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   16 |         gets(str);
      |         ~~~~^~~~~
main.cpp:18:13: warning: ignoring return value of ‘char* gets(char*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   18 |         gets(str);
      |         ~~~~^~~~~
main.cpp:20:13: warning: ignoring return value of ‘char* gets(char*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   20 |         gets(str);
      |         ~~~~^~~~~
main.cpp:22:13: warning: ignor

ソースコード

diff #

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

int main() {

	int d = 0;

	long int left = 0;
	long int center = 0;
	long int right = 0;

	char str[20];
	long int count = 0;

	gets(str);
	d = atoi(str);
	gets(str);
	left = atoi(str);
	gets(str);
	center = atoi(str);
	gets(str);
	right = atoi(str);

	if(!((center < left && center < right) || (center > left && center > right))){

		long int lc = left - center;
		long int rc = right - center;

		if(lc > 0){
			long double l = double(abs(lc)) / d;
			long double r = double(abs(rc)) / d;
			if(l > r)
				count = ceil(r);
			else
				count = ceil(l);

		} else {
			long double l = double(abs(lc)) / d;
			long double r = double(abs(rc)) / d;
			if (l > r)
				count = ceil(l);
			else
				count = ceil(r);


		}

	}
	else if((left == 0 && center == 0) || (right == 0 && center == 0))
		count = -1;


	printf("%ld",count);

	return 0;

}
0