結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー wait_sushiwait_sushi
提出日時 2018-09-14 22:29:44
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 234 ms / 5,000 ms
コード長 740 bytes
コンパイル時間 816 ms
コンパイル使用メモリ 68,452 KB
実行使用メモリ 8,224 KB
最終ジャッジ日時 2024-04-26 00:35:10
合計ジャッジ時間 7,061 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 234 ms
7,448 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 86 ms
6,940 KB
testcase_03 AC 167 ms
6,944 KB
testcase_04 AC 207 ms
6,944 KB
testcase_05 AC 207 ms
6,968 KB
testcase_06 AC 204 ms
6,940 KB
testcase_07 AC 221 ms
6,948 KB
testcase_08 AC 225 ms
7,204 KB
testcase_09 AC 230 ms
7,128 KB
testcase_10 AC 182 ms
7,676 KB
testcase_11 AC 192 ms
6,944 KB
testcase_12 AC 177 ms
7,484 KB
testcase_13 AC 209 ms
6,940 KB
testcase_14 AC 213 ms
6,940 KB
testcase_15 AC 191 ms
7,500 KB
testcase_16 AC 201 ms
6,944 KB
testcase_17 AC 203 ms
6,944 KB
testcase_18 AC 202 ms
6,948 KB
testcase_19 AC 224 ms
8,224 KB
testcase_20 AC 224 ms
6,940 KB
testcase_21 AC 222 ms
6,940 KB
testcase_22 AC 183 ms
8,136 KB
testcase_23 AC 201 ms
6,940 KB
testcase_24 AC 2 ms
6,940 KB
testcase_25 AC 6 ms
6,944 KB
testcase_26 AC 4 ms
6,940 KB
testcase_27 AC 3 ms
6,944 KB
testcase_28 AC 38 ms
6,940 KB
testcase_29 AC 19 ms
6,940 KB
testcase_30 AC 7 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

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