hdu 5108 Alexandra and Prime Numbers
2016-04-19 20:35
357 查看
数论题,本质是求出n的最大质因子
#include<time.h> #include <cstdio> #include <iostream> #include<algorithm> #include<math.h> #include <string.h> #include<vector> #include<queue> using namespace std; int main() { int n,t; while(scanf("%d",&n)!=EOF) { if(n == 1) //注意1不是素数,找不到最大质因子 { printf("0\n"); continue; } else { t=n; int maxx=1; for(int i=2;i<=int(sqrt(n));i++) while(t%i==0) { t/=i; maxx=i; } maxx=max(t,maxx); printf("%d\n",n/maxx); } } return 0; }
相关文章推荐
- leetcode----最长有效括号字串
- 【数据结构】二叉树的实现(如:默认成员函数、(叶子)节点数、深度、四种遍历)
- 写一个类的构造函数、复制构造函数、析构函数、赋值函数
- swift URL生成
- 正则表达式基础知识整理
- Android Builder模式
- nyoj1058 部分和问题
- 剪切坐标轴
- linux sysstat 安装使用
- 深入研究String StringBuffer StringBuilder 的拼接字符串
- Chilkat----开源站点之VS2010 CKMailMan一个很好的邮件发送开源开发包
- 《校园封神榜》个人工作总结——第二天
- 1000!的结果中如果用十进制表示,有多少位
- eclipse中的android项目转入android studio
- Oj平台-指针n个数逆序
- 《啊哈算法》第一章 排序
- jQuery学习(二)
- xml转换之
- 第一冲刺阶段工作总结01
- leetcode343-Integer Break(整数拆分求最大乘积)