結果
問題 | No.1271 初めての級数 |
ユーザー |
![]() |
提出日時 | 2020-10-30 23:26:58 |
言語 | C++14 (gcc 11.2.0 + boost 1.78.0) |
結果 |
AC
|
実行時間 | 17 ms / 2,000 ms |
コード長 | 820 bytes |
コンパイル時間 | 629 ms |
使用メモリ | 6,284 KB |
最終ジャッジ日時 | 2023-02-21 16:21:59 |
合計ジャッジ時間 | 1,619 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge11 |
テストケース
テストケース表示入力 | 結果 | 実行時間 使用メモリ |
---|---|---|
testcase_00 | AC | 17 ms
6,284 KB |
testcase_01 | AC | 2 ms
6,256 KB |
testcase_02 | AC | 2 ms
6,184 KB |
testcase_03 | AC | 2 ms
6,264 KB |
testcase_04 | AC | 1 ms
6,264 KB |
testcase_05 | AC | 2 ms
6,168 KB |
testcase_06 | AC | 2 ms
6,164 KB |
testcase_07 | AC | 2 ms
6,184 KB |
testcase_08 | AC | 1 ms
6,208 KB |
testcase_09 | AC | 1 ms
6,284 KB |
testcase_10 | AC | 1 ms
6,180 KB |
testcase_11 | AC | 1 ms
6,196 KB |
testcase_12 | AC | 2 ms
6,252 KB |
ソースコード
/* -*- coding: utf-8 -*- * * 1271.cc: No.1271 初めての級数 - yukicoder */ #include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> #include<iostream> #include<string> #include<vector> #include<map> #include<set> #include<stack> #include<list> #include<queue> #include<deque> #include<algorithm> #include<numeric> #include<utility> #include<complex> #include<functional> using namespace std; /* constant */ const int CNT = 10000000; /* typedef */ typedef long long ll; /* global variables */ /* subroutines */ /* main */ int main() { int k; scanf("%d", &k); double sum = 0.0; if (k == 0) { for (int i = CNT; i >= 1; i--) sum += 1.0 / ((ll)i * i); } else { for (int i = 1; i <= k; i++) sum += 1.0 / i; sum /= k; } printf("%.16lf\n", sum); return 0; }