結果

問題 No.1118 sin(x)/xの二乗和
ユーザー SamShawCraftSamShawCraft
提出日時 2022-10-19 08:12:40
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 233 ms / 2,000 ms
コード長 452 bytes
コンパイル時間 744 ms
コンパイル使用メモリ 86,788 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-11 23:01:26
合計ジャッジ時間 7,462 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 230 ms
4,380 KB
testcase_01 AC 232 ms
4,380 KB
testcase_02 AC 231 ms
4,376 KB
testcase_03 AC 233 ms
4,380 KB
testcase_04 AC 231 ms
4,380 KB
testcase_05 AC 230 ms
4,380 KB
testcase_06 AC 229 ms
4,380 KB
testcase_07 AC 228 ms
4,380 KB
testcase_08 AC 231 ms
4,376 KB
testcase_09 AC 227 ms
4,384 KB
testcase_10 AC 230 ms
4,380 KB
testcase_11 AC 232 ms
4,376 KB
testcase_12 AC 229 ms
4,376 KB
testcase_13 AC 229 ms
4,380 KB
testcase_14 AC 231 ms
4,376 KB
testcase_15 AC 232 ms
4,376 KB
testcase_16 AC 228 ms
4,376 KB
testcase_17 AC 230 ms
4,376 KB
testcase_18 AC 231 ms
4,380 KB
testcase_19 AC 232 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>
const int replim=1e7+9;
double x,ans,base;
int main(){
  std::cin>>x;
  std::cout<<std::setprecision(10)<<std::fixed;
  ans=std::sin(x)/x*std::sin(x)/x;
  base=1./(x+1.);
  for(int cx=1;cx<=replim;++cx)
    base+=1./(x+cx)/(x+cx)/(x+cx+1);
  for(int cx=1;cx<=replim;++cx)
    base-=std::cos(2*(x+cx))/(x+cx)/(x+cx);
  ans+=.5*base;
  std::cout<<ans<<std::endl;
  return 0;
}
0