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 ;
}
题目比较水,但是还是发现一些小问题 ;细节。。注重细节
#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 ;
}
相关文章推荐
- HDU 1164 Eddy's research I 数论
- hdu 1164 Eddy's research I
- hdu 1164 Eddy's research I
- HDU_1164 Eddy's research I
- HDU 1164 Eddy's research I
- hdu-oj 1164 Eddy's research I
- 整数分解(3种算法比较):hdu 1164 Eddy's research I+poj 1811 Prime Test
- hdu 1164 Eddy's research I
- hdu 1164 Eddy's research I
- HDU1164_Eddy's research I【Miller Rabin素数测试】【Pollar Rho整数分解】
- HDU1164 Eddy's research I
- HDU 1164 Eddy's research I
- HDU 1164 Eddy's research I
- hdu1164 Eddy's research I
- HDU 1164 Eddy's research I
- hdu 1164 Eddy's research I (数论)
- HDU1164 Eddy's research I
- hdu 1164 Eddy's research I
- hdu(1164)Eddy's research I
- hdu1164 Eddy's research I