結果
問題 | No.1118 sin(x)/xの二乗和 |
ユーザー |
|
提出日時 | 2020-07-18 15:51:14 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 6 ms / 2,000 ms |
コード長 | 411 bytes |
コンパイル時間 | 738 ms |
コンパイル使用メモリ | 49,536 KB |
最終ジャッジ日時 | 2025-01-12 00:18:30 |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 20 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:17:18: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 17 | double x; scanf("%lf", &x); | ~~~~~^~~~~~~~~~~
ソースコード
#include <cmath>#include <cstdio>using namespace std;double f(double x) {if(abs(x) < 1e-15) { return 2.07079632677096370230; }constexpr int n = 100000;double res = 1 / (2. * (x + n + .5));for(int i=0; i<n; ++i) {double t = sin(x + i) / (x + i);res += t*t;}return res;}int main(void) {double x; scanf("%lf", &x);double res = f(x);printf("%.15lf\n", res);return 0;}