結果

問題 No.454 逆2乗和
ユーザー @abcde@abcde
提出日時 2019-06-01 21:10:06
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 304 ms / 2,000 ms
コード長 1,133 bytes
コンパイル時間 1,470 ms
コンパイル使用メモリ 165,828 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-17 22:51:18
合計ジャッジ時間 13,538 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

// TODO: 解答方針不明.
// TODO: MLE改善.
#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e8;
double cur, bef;

int main() {
    
    // 1. 入力情報取得.
    double x;
    scanf("%lf", &x);
    
    // 2. 100000000 まで, 計算してみる.
    for(int i = 1; i < MAX + 1; i++){
        // 今回分を計算.
        double d = 1.0 / (i + x + 0.0);
        d /= (i + x + 0.0);
        cur = bef + d;
        
        // 前回の計算結果に保存.
        bef = cur;
    }
    
    // 3. 倍率してみる(※とりあえず実装).
    // x = 0:    1.6449340668482264    ÷ 1.64493405783457503 = 約 1.000000005479642984513倍
    // x = 1.5:  0.490357756100235     ÷ 0.49035774607552685 = 約 1.000000020443662265419倍
    // x = 1000: 0.0009995001666667166 ÷ 0.00099949016676597 = 約 1.000010005001628936956倍
    // -> 1.000000005479642984513 × (1.0 + x * 1e-8) と仮定して, 倍率をかけてみる.
    double eps = 1.000000005479642984513 * (1.0 + (x + 0.0) / MAX);
    double ans = eps * cur;
    
    // 4. 出力 ~ 後処理.
    printf("%.17lf\n", ans);
    return 0;
    
}
0