tjut 4944

来源:互联网 发布:编程英语词汇大全app 编辑:程序博客网 时间:2024/06/05 00:32
#include <cstdio>  #include <cmath>  #include <cstdlib>  #include <cstring>  #include <vector>  #include <map>  #include <iostream>  #include <algorithm>  using namespace std;    #define LL __int64  const int maxn=5e5+20;  LL mod;  LL val[maxn],dp[maxn];    void fun(int n)  {      for(LL i=1;i<n;i++)//枚举因子      {          for(LL j=i;j<n;j+=i)//枚举含有因子的数          {              val[j]+=(j/i+1)*(j/i)/2;          }      }  }  void init()  {      mod=1;      mod=(mod<<32);      memset(val,0,sizeof(val));      fun(maxn);      dp[1]=1;      for(LL i=2;i<maxn;i++)//递推公式      {          dp[i]=dp[i-1]+val[i]*i;          dp[i]=dp[i]%mod;      }  }  int main()  {      init();      int n,tt=0,T;      scanf("%d",&T);      while(T--)      {          scanf("%d",&n);          printf("Case #%d: %I64d\n",++tt,dp[n]);      }      return 0;  } 

0 0
原创粉丝点击