hdu1299

 1 #include<stdio.h>
 2 #include<math.h>
 3 int vis[100005],prime[100005];
 4 int main()
 5 {
 6     int cnt,dd,i,j,t,T,n,ans,temp;
 7     cnt=0; dd=int(1.0*sqrt(1000000000.0)+1);
 8     for (i=1;i<=dd;i++) vis[i]=0;
 9     for (i=2;i<=dd;i++)
10     if (vis[i]==0)
11     {
12         cnt++;
13         prime[cnt]=i;
14         for (j=i*i;j<=dd;j+=i) vis[j]=1;
15     }
16 //  for (i=1;i<=10;i++) printf("%d ",prime[i]);
17     scanf("%d",&T);
18     for (t=1;t<=T;t++)
19     {
20         scanf("%d",&n);
21         ans=1;
22         for (i=1;i<=cnt;i++)
23         {
24           if (prime[i]>n) break;
25             temp=0;
26             while (n%prime[i]==0) {temp++; n/=prime[i]; }
27             temp=temp*2+1;
28             ans*=temp;
29         }
30         if (n>1) ans*=3;
31         printf("Scenario #%d:\n",t);
32         printf("%d\n\n",(ans+1)/2);
33     }
34 }

http://acm.hdu.edu.cn/showproblem.php?pid=1299

posted on 2014-07-16 14:29  xiao_xin  阅读(236)  评论(0编辑  收藏  举报

导航