結果
問題 | No.67 よくある棒を切る問題 (1) |
ユーザー | ciel |
提出日時 | 2014-11-16 23:41:59 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 166 ms / 5,000 ms |
コード長 | 427 bytes |
コンパイル時間 | 518 ms |
コンパイル使用メモリ | 36,608 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-08 11:14:50 |
合計ジャッジ時間 | 5,574 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 31 |
コンパイルメッセージ
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); }