HDU1164质数
来源:互联网 发布:彩票开奖数据采集源码 编辑:程序博客网 时间:2024/06/05 12:39
Eddy’s research I
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 10378 Accepted Submission(s): 6417Problem Description
Eddy’s interest is very extensive, recently he is interested in prime number. Eddy discover the all number owned can be divided into the multiply of prime number, but he can’t write program, so Eddy has to ask intelligent you to help him, he asks you to write a program which can do the number to divided into the multiply of prime number factor .Input
The input will contain a number 1 < x<= 65535 per line representing the number of elements of the set.Output
You have to print a line in the output for each entry with the answer to the previous question.Sample Input
11
9412Sample Output
11
2*2*13*181
思路
题意就是输入一个数,然后这个数由几个质数相乘得到,如果这个是质数,直接输出
代码
#include <iostream>#include <stdio.h>using namespace std;bool is_prime(int n){//判断质数 if (n < 2){ return false; } int i; for (i = 2; i*i <= n; i++){ if (n%i == 0){ return false; } } return true;}int main(){ int n; while(cin>>n) { int i=2; int m=1; if(is_prime(n)) cout<<n<<endl; else { int i=2; while(i<=n) { if(n%i==0) { if(n==i) { cout<<n<<endl; break; } else cout<<i<<"*"; n/=i; } else { i++; continue; } } } } return 0;}
- HDU1164质数
- HDU1164
- HDU1164
- hdu1164
- hdu1164
- hdu1164
- hdu1164
- HDU1164
- HDU1164
- 数论第一题HDU1164
- HDU1164质因数分解
- hdu1164(素数筛选)
- 质数
- 质数
- 质数
- 质数
- 质数
- 质数
- cnn卷积神经网络讲解清晰的一篇文章
- dede后台生产网页显示“模板文件不存在 无法解析文档”
- 搜索引擎选择: Elasticsearch与Solr
- Android开发之Activity的生命周期
- Apache Shiro 实现方法级别细粒度权限控制
- HDU1164质数
- caffe 训练自己的数据
- mybatis跋涉
- hdu 3746 Cyclic Nacklace (KMP+分类讨论)
- 阿里java高级工程师面试题
- Hadoop(4-3)-MapReduce程序案例-统计每一年最高温度
- 分布式缓存系统TAIR代码分析二
- HDU6103(Kirinriki)
- java验证码--应用验证码jar包