http://acm.fzu.edu.cn/problem.php?pid=2037
思路:找规律,找出递推公式f[n]=f[n-1]*n+(n-1)!,另一个的结果也是一个递推,s[n]=s[n-1]+1/n;
#include <cstdio>
#include <cstring>
#include <algorithm>
#define maxn 1000010
#define ll long long
using namespace std;
const int mod=; ll f[maxn];
int t;
ll n;
ll h[maxn];
double ans[maxn]; void inti()
{
h[]=;
h[]=;
ans[]=1.0;
for(int i=; i<=maxn; i++)
{
ans[i]=ans[i-]+1.0/i;
h[i]=h[i-]*i;
h[i]%=mod;
}
f[]=;
for(int i=; i<=maxn; i++)
{
f[i]=(f[i-]*i+h[i-])%mod;
}
} int main()
{
inti();
scanf("%d",&t);
for(int cas=; cas<=t; cas++)
{
scanf("%lld",&n);
printf("Case %d: %I64d %.6lf\n",cas,f[n],ans[n]);
}
return ;
}