标签:2014百度之星初赛第二场 数论
3 1 2 3
Case #1: 2 Case #2: 4 Case #3: 7
#include<cstdio>
#include<algorithm>
#define LL long long
#define MAX 10000005
using namespace std;
LL ans[MAX];
LL Count[MAX];
void GetOddNum()//计算奇约数的个数
{
for(int i=1;i<=MAX;i+=2)
{
for(int j=i;j<=MAX;j+=i)
Count[j]++;
}
}
void Init()
{
ans[0]=1;
ans[1]=2;
LL cnt=1;
for(int i=2;i<MAX;i++)
{
cnt+=Count[i-1];
ans[i]=ans[i-1]+cnt;
}
}
int main(int argc,char *argv[])
{
GetOddNum();
Init();
int t;
int n;
scanf("%d",&t);
for(int i=1;i<=t;i++)
{
scanf("%d",&n);
printf("Case #%d:\n%I64d\n",i,ans[n]);
}
}
2014百度之星初赛(第二场)——JZP Set,布布扣,bubuko.com
标签:2014百度之星初赛第二场 数论
原文地址:http://blog.csdn.net/cstopcoder/article/details/27235923