博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
HDU5108
阅读量:4626 次
发布时间:2019-06-09

本文共 761 字,大约阅读时间需要 2 分钟。

题意:给你一个正整数n, 找到一个最小的数m,使得n/m为质数。

题解:质因数分解

1 #include 
2 #include
3 #include
4 typedef long long ll; 5 6 int main() 7 { 8 ll n; 9 while( ~scanf( "%I64d", &n ) )10 {11 if( n == 1 )12 {13 puts( "0" );14 continue;15 }16 ll ans = n, cnt;17 for( ll i = 2; i*i <= n; ++i )18 if( n % i == 0 )19 {20 while( n % i == 0 ) {21 n /= i;22 cnt = i;23 }24 }25 if( n > 1 ) cnt = n;26 printf( "%I64d\n", ans/cnt );27 }28 return 0;29 }
View Code

 

转载于:https://www.cnblogs.com/ADAN1024225605/p/4116369.html

你可能感兴趣的文章
leetcode刷题七<整数反转>
查看>>
Apache部署Django过程中遇到的一些问题
查看>>
asp.net 页面定时跳转的小技巧
查看>>
java继承
查看>>
python(2)-函数相关
查看>>
HDU 2120 Ice_cream's world I
查看>>
PAT 1034 有理数四则运算
查看>>
redis性能优化——生产中实际遇到的问题排查总结
查看>>
linux(Ubuntu)下安装JDK
查看>>
Python基础:输入与输出(I/O)
查看>>
C++ 11 学习3:显示虚函数重载(override)
查看>>
简单回溯,最少步数
查看>>
表面积最小(POJ3536)
查看>>
2013 Asia Regional Changchun I 题,HDU(4821),Hash
查看>>
分布式锁实践(二)-ZooKeeper实现总结
查看>>
POJ 1004
查看>>
Item 26: Avoid Returning References to Internal Class Objects(Effective C#)
查看>>
Rule 5: Put Stylesheets at the Top(Chapter 5 of High performance Web Sites)
查看>>
如何让你的移动端网站更快
查看>>
编译原理
查看>>