結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー wait_sushiwait_sushi
提出日時 2018-09-14 22:29:44
言語 C++11
(gcc 13.3.0)
結果
AC  
実行時間 240 ms / 5,000 ms
コード長 740 bytes
コンパイル時間 1,170 ms
コンパイル使用メモリ 67,320 KB
実行使用メモリ 6,912 KB
最終ジャッジ日時 2024-11-08 12:47:03
合計ジャッジ時間 7,082 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <iomanip>
#include<math.h>
using namespace std;
long long int N,i=0;
long double K;
long double L[300000];
void nibutan(long double s,long double t);
bool f(long double x);

int main(){
    //long double s,t;
    cin>>N;
    for(int j=0;j<N;j++){
        cin>>L[j];
    }
    cin>>K;
    nibutan(0.000000001,1000000000);
}

void nibutan(long double s,long double t){
long double ng = s, ok = t;
while (i<100) {
    long double mid = (ng + ok) / 2;
     (f(mid) ? ok : ng) = mid;
    //cout<<mid<<endl;
     i++;
}
    fixed;
    cout<<setprecision(10)<<ok<<endl;
}

bool f(long double x){
    long long int s=0;
    for(int j=0;j<N;j++){
        s+=L[j]/x;
    }
    if(K>s)return true;
    else return false;
}
0