結果
問題 | No.881 sin(x)/xの和 |
ユーザー |
|
提出日時 | 2019-09-07 12:51:33 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,570 bytes |
コンパイル時間 | 1,509 ms |
コンパイル使用メモリ | 169,060 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-11-21 08:01:49 |
合計ジャッジ時間 | 6,139 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 22 WA * 1 |
ソースコード
#include <bits/stdc++.h>#define rep(i, n) for (int i = 0; i < (n); i++)#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)#define range(a) a.begin(), a.end()using namespace std;using ll = long long;double sinc(double x) {if (abs(x) < 1e-6) return 1;return sin(x) / x;}double g(double x) {double ans = 0;for (int j = -100000; j <= 100000; j++) {ans += sinc(x + j);}return ans;}double f(double x) {double ans = 0;for (int j = 10; j < 10000; j++) {// sin(x+j)// ------- * sin(1/2)// x+j//// cos(x+j-1/2) - cos(x+j+1/2)// ---------------------------// x+j//// cos(x+j+1/2) - cos(x+j+1/3)// ---------------------------// x+j+1//// cos(x+j+1/2)//// 1 1// ------- - -----// x+j+1 x+j//// -1// ----------------// (x+j)(x+j+1)// j=10ans -= 1/(x+j)/(x+j+1) * cos(x+j+0.5);ans -= 1/(x-j)/(x-j-1) * cos(x-j-0.5);}for (int j = -9; j <= 9; j++) {ans += sinc(x + j) * sin(0.5) * 2;}ans += cos(x+10-0.5)/(x+10);ans -= cos(x-10+0.5)/(x-10);return ans / (2 * sin(0.5));}int main() {cin.tie(nullptr);ios::sync_with_stdio(false);int N; cin >> N;double ans = 0;rep(i, N) {double x, a; cin >> x >> a;ans += a * f(x);}cout << fixed << setprecision(15) << ans << endl;}