結果
| 問題 |
No.454 逆2乗和
|
| コンテスト | |
| ユーザー |
wafrelka
|
| 提出日時 | 2016-12-06 01:59:40 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 489 bytes |
| コンパイル時間 | 196 ms |
| コンパイル使用メモリ | 23,808 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-30 02:55:05 |
| 合計ジャッジ時間 | 1,512 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 31 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:10:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
10 | scanf("%lf", &x);
| ~~~~~^~~~~~~~~~~
ソースコード
#include <cstdio>
const double PI = 3.1415926535897932384626433832;
int main()
{
const int limit = 100000;
double x;
scanf("%lf", &x);
double pre = 0;
double orig_pre = 0;
for(int i = 1; i < limit; ++i)
pre += 1.0 / ((x + i) * (x + i));
for(int i = 1; i < limit + x; ++i)
orig_pre = orig_pre + 1.0 / ((double)i * i);
double orig_total = PI / 6 * PI;
double orig_remain = orig_total - orig_pre;
double ans = pre + orig_remain;
printf("%.20lf\n", ans);
return 0;
}
wafrelka