結果

問題 No.881 sin(x)/xの和
ユーザー pekempeypekempey
提出日時 2019-09-07 12:51:33
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,570 bytes
コンパイル時間 1,635 ms
コンパイル使用メモリ 165,840 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-13 13:01:53
合計ジャッジ時間 6,296 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 294 ms
4,380 KB
testcase_01 WA -
testcase_02 AC 106 ms
4,380 KB
testcase_03 AC 118 ms
4,376 KB
testcase_04 AC 338 ms
4,376 KB
testcase_05 AC 52 ms
4,380 KB
testcase_06 AC 32 ms
4,380 KB
testcase_07 AC 59 ms
4,376 KB
testcase_08 AC 270 ms
4,380 KB
testcase_09 AC 147 ms
4,376 KB
testcase_10 AC 123 ms
4,376 KB
testcase_11 AC 203 ms
4,376 KB
testcase_12 AC 253 ms
4,376 KB
testcase_13 AC 124 ms
4,376 KB
testcase_14 AC 75 ms
4,376 KB
testcase_15 AC 73 ms
4,380 KB
testcase_16 AC 169 ms
4,376 KB
testcase_17 AC 66 ms
4,376 KB
testcase_18 AC 103 ms
4,380 KB
testcase_19 AC 156 ms
4,380 KB
testcase_20 AC 27 ms
4,380 KB
testcase_21 AC 162 ms
4,380 KB
testcase_22 AC 350 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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=10
    ans -= 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;
}
0