結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー cielciel
提出日時 2014-11-16 23:41:59
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 164 ms / 5,000 ms
コード長 427 bytes
コンパイル時間 297 ms
コンパイル使用メモリ 36,736 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-25 23:05:19
合計ジャッジ時間 5,004 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 158 ms
6,812 KB
testcase_01 AC 1 ms
6,940 KB
testcase_02 AC 58 ms
6,940 KB
testcase_03 AC 112 ms
6,944 KB
testcase_04 AC 151 ms
6,944 KB
testcase_05 AC 154 ms
6,940 KB
testcase_06 AC 161 ms
6,944 KB
testcase_07 AC 164 ms
6,940 KB
testcase_08 AC 154 ms
6,944 KB
testcase_09 AC 148 ms
6,940 KB
testcase_10 AC 136 ms
6,940 KB
testcase_11 AC 146 ms
6,940 KB
testcase_12 AC 134 ms
6,940 KB
testcase_13 AC 143 ms
6,940 KB
testcase_14 AC 145 ms
6,944 KB
testcase_15 AC 126 ms
6,944 KB
testcase_16 AC 150 ms
6,940 KB
testcase_17 AC 150 ms
6,944 KB
testcase_18 AC 150 ms
6,940 KB
testcase_19 AC 151 ms
6,940 KB
testcase_20 AC 150 ms
6,944 KB
testcase_21 AC 149 ms
6,940 KB
testcase_22 AC 135 ms
6,944 KB
testcase_23 AC 142 ms
6,944 KB
testcase_24 AC 1 ms
6,940 KB
testcase_25 AC 4 ms
6,944 KB
testcase_26 AC 2 ms
6,940 KB
testcase_27 AC 2 ms
6,940 KB
testcase_28 AC 26 ms
6,940 KB
testcase_29 AC 13 ms
6,940 KB
testcase_30 AC 4 ms
6,940 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:6:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    6 |         scanf("%d",&n);
      |         ~~~~~^~~~~~~~~
main.cpp:9:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    9 |                 scanf("%lf",&v[i]);
      |                 ~~~~~^~~~~~~~~~~~~
main.cpp:11:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   11 |         scanf("%lld",&k);
      |         ~~~~~^~~~~~~~~~~

ソースコード

diff #

#include <vector>
#include <cstdio>
int main(){
	int n;
	long long k;
	scanf("%d",&n);
	std::vector<double>v(n);
	for(int i=0;i<n;i++){
		scanf("%lf",&v[i]);
	}
	scanf("%lld",&k);
	double mi=0,ma=1e9;
	//for(;mi+1e-9<ma;){
	for(int x=0;x<100;x++){
		long long _n=0;
		double h=(mi+ma)/2;
		for(int i=0;i<n;i++){
			_n+=v[i]/h;
		}
		if(_n>=k){
			mi=h;
		}else{
			ma=h;
		}
	}
	printf("%.9f\n",mi);
}
0