您的位置:首页 > 其它

hdu1164-Eddy's research I

2013-06-06 11:01 344 查看
http://acm.hdu.edu.cn/showproblem.php?pid=1164

题目比较水,但是还是发现一些小问题 ;细节。。注重细节

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>

using namespace std ;
#define INT __int64

bool judge( INT n )
{
for( INT i = 2 ; i <= sqrt((double) n ) ; i++ )
if( n % i == 0 )
return false ;
return true ;
}
int main()
{
INT n ;
while( cin >> n )
{
if( judge( n ) )
cout << n << endl ;
else
{
INT i = 2 ;
while( i <= sqrt( ( double ) n ) )
{
if( n % i == 0 )
{
cout << i << "*" ;
n /= i ;
i = 2 ;
}
else
++i;
}
cout << n << endl ;
}
}
return 0 ;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  杭电