hoj1299

Problem : 1299 ( Diophantus of Alexandria )     Judge Status : Accepted
RunId : 2814216    Language : C++    Author : huwenbiao
Code Render Status : Rendered By HDOJ C++ Code Render Version 0.01 Beta
//*========================*Head File*========================*\\

#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
/*----------------------*Global Variable*----------------------*/
bool
isprime[
31625];
int
prime[
15825];
int
T,n,pos,ans,cnt,_max,tmp;

//*=======================*Main Program*=======================*//
using namespace std;

int
main(){

//freopen("input","r",stdin);
cnt=0;
_max=
31623;
prime[cnt++]=
2;
for
(int i=
3;i<=_max;i+=2){
if
(!isprime[i]){
prime[cnt++]=i;
for
(int j=
3*i;j<=_max;j+=i<<1)
isprime[j]=
true;
}
}

scanf(
"%d",&T);
for
(int i=
1;i<=T;i++){
scanf(
"%d",&n);
pos=
0;
ans=
1;
while
(pos<cnt&&n>
1){
tmp=
0;
while
(n%prime[pos]==
0){
tmp+=
2;
n/=prime[pos];
}

ans*=(tmp+
1);
pos++;
}

if
(n>
1){//现在n是素数
ans*=3;
}

ans=(ans+
1)>>1;
printf(
"Scenario #%d:\n%d\n\n",i,ans);
}
}
posted @ 2010-08-14 08:33  open source  阅读(135)  评论(0编辑  收藏  举报