結果
問題 | No.454 逆2乗和 |
ユーザー |
|
提出日時 | 2020-06-01 15:43:13 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 368 ms / 2,000 ms |
コード長 | 551 bytes |
コンパイル時間 | 2,330 ms |
コンパイル使用メモリ | 191,132 KB |
最終ジャッジ日時 | 2025-01-10 20:17:31 |
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 31 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:21:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 21 | scanf("%lf",&q); | ~~~~~^~~~~~~~~~
ソースコード
#include <bits/stdc++.h>#define rep(i,n) for(int i=0;i<(n);i++)using namespace std;/*Hurwitz zetaζ(s,q) = Sum_{n=0}^∞ 1/(q+n)^s= (1/Γ(s)) ∫_0^∞ t^{s-1}exp(-qt)/(1-exp(-t))dt*/double q;double f(double x){if(x==0) return 1;else return x*exp(-q*x)/(1-exp(-x));}int main(){scanf("%lf",&q);q++;double res=0;int N=1e7;double L=1e2;rep(i,N+1){double w;if(i==0 || i==N) w=1;else if(i%2==1) w=4;else w=2;res+=w*f(i*L/N);}res*=L/(3*N);printf("%.15f\n",res);return 0;}