結果
問題 |
No.454 逆2乗和
|
ユーザー |
![]() |
提出日時 | 2016-12-06 02:04:28 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 471 bytes |
コンパイル時間 | 195 ms |
コンパイル使用メモリ | 23,424 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-27 22:49:22 |
合計ジャッジ時間 | 1,180 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
other | AC * 13 WA * 18 |
コンパイルメッセージ
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.1415926535897932384626; int main() { const int limit = 10000; 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 += 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; }