結果
| 問題 | No.67 よくある棒を切る問題 (1) | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2014-11-16 23:41:59 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 156 ms / 5,000 ms | 
| コード長 | 427 bytes | 
| コンパイル時間 | 449 ms | 
| コンパイル使用メモリ | 43,008 KB | 
| 実行使用メモリ | 8,604 KB | 
| 最終ジャッジ日時 | 2025-03-03 10:03:41 | 
| 合計ジャッジ時間 | 5,100 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 30 | 
コンパイルメッセージ
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);
      |         ~~~~~^~~~~~~~~~~
            
            ソースコード
#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);
}
            
            
            
        