結果

問題 No.3072 Sum of sqrt(x)
ユーザー くろんくろん
提出日時 2023-09-21 21:37:45
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 691 bytes
コンパイル時間 2,288 ms
コンパイル使用メモリ 67,376 KB
実行使用メモリ 8,752 KB
最終ジャッジ日時 2023-09-21 21:38:01
合計ジャッジ時間 13,312 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 2 ms
4,380 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 TLE -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cmath>

using namespace std;

double binomialCoefficients(double alpha, int k);

int main() {
    int N;
    cin >> N;
    
    double x_i[N];
    for(int i = 0; i < N; i++){
    	cin >> x_i[i];
    	if(x_i[i] > 1) x_i[i] = 1/x_i[i];
    	
    	double result = 0;
    	for(int j = 0; j < 19; j++){
    		double buff = 0;
    		for(int k = 0; k < i; k++ ) buff += pow(x_i[k] - 1, j);
    		
    		result += binomialCoefficients(0.5, j) * buff;
    	}
    	
    	cout << result << endl;
    }
    
    return 0;
}

double binomialCoefficients(double alpha, int k){
	double result = 1;
	for(int i = 0; i < k; i++) result *= (alpha - k)/(k + 1);
	
	return result;
}
0