题目太神了,证明还需要用到生成函数。
鉴于自己太菜,直接抄别人的结果好了。
#include <map> #include <cmath> #include <queue> #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; #define F(i,j,k) for (int i=j;i<=k;++i) #define D(i,j,k) for (int i=j;i>=k;--i) #define ll long long #define mp make_pair int n; ll ans; int main() { scanf("%d",&n); printf("%.9lf ",(double)(n/2.0/(2*n-1)*(n+1))); }