关闭

fzu 2037 卡内存的坑爹题

标签: oo
368人阅读 评论(0) 收藏 举报
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<cmath>
#include<cassert>
#include<cstring>
#include<iomanip>
using namespace std;

#ifdef _WIN32
#define i64 __int64
#define out64 %I64d
#define in64 "%I64d"
#else
#define i64 long long
#define out64 %lld
#define in64 "%lld"
#endif

#define FOR(i,a,b)      for( int i = (a) ; i <= (b) ; i ++)
#define FF(i,a)         for( int i = 0 ; i < (a) ; i ++)
#define FFD(i,a)        for( int i = (a)-1 ; i >= 0 ; i --)
#define S64(a)          scanf(in64,&a)
#define SS(a)           scanf("%d",&a)
#define LL(a)           ((a)<<1)
#define RR(a)           (((a)<<1)+1)
#define SZ(a)           ((int)a.size())
#define PP(n,m,a)       puts("---");FF(i,n){FF(j,m)cout << a[i][j] << ' ';puts("");}
#define pb              push_back
#define CL(Q)           while(!Q.empty())Q.pop()
#define MM(name,what)   memset(name,what,sizeof(name))
#define read            freopen("in.txt","r",stdin)
#define write           freopen("out.txt","w",stdout)

const int inf = 0x3f3f3f3f;
const i64 inf64 = 0x3f3f3f3f3f3f3f3fLL;
const double oo = 10e9;
const double eps = 10e-10;
const double pi = acos(-1.0);
const int maxn = 1000005;
const int mod = 1000000007;

double dps[maxn];
i64 dp[maxn];
i64 a[maxn];
int T;

void init()
{
    dps[0] = 0.0;
    dps[1] = 1.0;
    dps[2] = 1.5;

    dp[0] = 0;
    dp[1] = 1;
    dp[2] = 3;
    a[0] = 1;
    a[1] = 1;
    a[2] = 2;
    for(int i=3;i<maxn;i++)
    {
    //    dps[i] = dps[i-1]/i + dps[i-1] + 1.0;
        dps[i] = dps[i-1] + 1.0/i;
        a[i] = a[i-1]*i;
        a[i]%=mod;

        dp[i] = dp[i-1]*i + a[i-1];
        dp[i]%=mod;
    }
    return ;
}
int x;
double pp;
int main()
{
    init();
    cin>>T;
    for(int tt=1;tt<=T;tt++)
    {
        SS(x);
        printf("Case %d: ",tt);
        printf("%I64d ",dp[x]);
        printf("%.6lf\n",dps[x]);
    }
    return 0;
}


0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:331624次
    • 积分:6311
    • 等级:
    • 排名:第3889名
    • 原创:299篇
    • 转载:19篇
    • 译文:0篇
    • 评论:126条
    最新评论