結果
問題 | No.67 よくある棒を切る問題 (1) |
ユーザー |
![]() |
提出日時 | 2015-04-30 22:57:28 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 44 ms / 5,000 ms |
コード長 | 499 bytes |
コンパイル時間 | 1,416 ms |
コンパイル使用メモリ | 154,976 KB |
実行使用メモリ | 8,608 KB |
最終ジャッジ日時 | 2025-03-03 10:18:12 |
合計ジャッジ時間 | 3,474 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 30 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:18:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 18 | scanf("%d",&N); | ~~~~~^~~~~~~~~ main.cpp:19:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 19 | for(int i=0;i<N;i++)scanf("%d",&L[i]); | ~~~~~^~~~~~~~~~~~ main.cpp:20:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 20 | scanf("%lld",&K); | ~~~~~^~~~~~~~~~~
ソースコード
#include<bits/stdc++.h> using namespace std; typedef long long ll; int N; int L[200000]; ll K; ll f(double x){ double d=1.0/x; ll ret=0; for(int i=0;i<N;i++)ret+=(ll)(L[i]*d); return ret; } int main(){ scanf("%d",&N); for(int i=0;i<N;i++)scanf("%d",&L[i]); scanf("%lld",&K); double lb=0,ub=1e10; for(int i=0;i<100;i++){ double mid=(ub+lb)/2; if(f(mid)>=K)lb=mid; else ub=mid; } printf("%.10lf\n",(ub+lb)/2); return 0; }