結果

問題 No.3072 Sum of sqrt(x)
ユーザー trineutrontrineutron
提出日時 2020-06-05 18:51:24
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,740 ms / 2,000 ms
コード長 443 bytes
コンパイル時間 1,042 ms
コンパイル使用メモリ 83,080 KB
実行使用メモリ 5,008 KB
最終ジャッジ日時 2023-09-15 01:11:18
合計ジャッジ時間 151,813 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 3 ms
4,384 KB
testcase_02 AC 3 ms
4,384 KB
testcase_03 AC 3 ms
4,384 KB
testcase_04 AC 3 ms
4,380 KB
testcase_05 AC 3 ms
4,380 KB
testcase_06 AC 2 ms
4,384 KB
testcase_07 AC 1,485 ms
4,380 KB
testcase_08 AC 644 ms
4,384 KB
testcase_09 AC 866 ms
4,388 KB
testcase_10 AC 1,720 ms
4,388 KB
testcase_11 AC 1,700 ms
4,388 KB
testcase_12 AC 1,740 ms
4,388 KB
testcase_13 AC 1,693 ms
4,384 KB
testcase_14 AC 1,693 ms
4,388 KB
testcase_15 AC 1,713 ms
4,388 KB
testcase_16 AC 1,685 ms
4,388 KB
testcase_17 AC 1,678 ms
4,388 KB
testcase_18 AC 1,721 ms
5,008 KB
testcase_19 AC 1,678 ms
4,384 KB
testcase_20 AC 1,691 ms
4,388 KB
testcase_21 AC 1,684 ms
4,388 KB
testcase_22 AC 1,706 ms
4,388 KB
testcase_23 AC 1,698 ms
4,384 KB
testcase_24 AC 1,691 ms
4,388 KB
testcase_25 AC 1,689 ms
4,384 KB
testcase_26 AC 1,689 ms
4,384 KB
testcase_27 AC 1,527 ms
4,384 KB
testcase_28 AC 1,568 ms
4,384 KB
testcase_29 AC 1,594 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <iomanip>
#include <cmath>

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cout << std::setprecision(17);
    int n;
    std::cin >> n;
    long double s = 0, t, r = 0;
    for (int i = 0; i < n; i++) {
        long double x;
        std::cin >> x;
        x = sqrtl(x) + r;
        t = s + x;
        r = x - (t - s);
        s = t;
        std::cout << s << "\n";
    }
}
0