Eddy's research I

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)

Total Submission(s): 7537 Accepted Submission(s): 4579

Problem 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
9412
Sample Output
11
2*2*13*181
Author
eddy
Recommend
JGShining | We have carefully selected several similar problems for you:

pid=1215">1215

pid=1211">
1211

pid=1299">
1299

pid=1163">
1163
1128


#include<stdio.h>
int main(){
int x,i;
while(~scanf("%d",&x)){
i=2;
while(1){
if(i==x) {
printf("%d\n",i);
break;
}
if(x%i==0) {
printf("%d*",i);
x/=i;
}
else {
++i;
} }
}
return 0;
}

刚開始不明确为什么可以直接进行++i,而不再考虑 i 是否为质数,之后才明确过来: 由于从2開始分解,一直分解到剩下的因子不再可以被2整除为止,才进行对下一个数的分解,而 对于合数。它总可以分解为几个素数的乘积;然而此合数的素数因子已经在之前都被全然提取出来了,所以对于x 是合数的情况。不可能再找到 x%i==0 (注意:此处的X已经不是最開始输入的那个x了),另外:每一个素数之间又没有什么关系,先去分解哪个质数,其终于得到的质因子是全然一样的,所以也不用操心前面的分解结果会对后面的分解造成影响。!!

hdoj-1164-Eddy&#39;s research I【分解质因数】的更多相关文章

  1. HDU 1164 Eddy&#39;s research I【素数筛选法】

    思路:将输入的这个数分成n个素数的相乘的结果,用一个数组存储起来.之后再输出就能够了 Eddy's research I Time Limit: 2000/1000 MS (Java/Others)  ...

  2. HDOJ 1164 Eddy's research I(拆分成素数因子)

    Problem Description Eddy's interest is very extensive, recently he is interested in prime number. Ed ...

  3. HDOJ 1164 Eddy's research I

    Problem Description Eddy's interest is very extensive, recently he is interested in prime number. Ed ...

  4. HDOJ 1164 Eddy's research

    上一篇已经讲了,但是转载别人的很乱,这里自己根据blog里面写的思路,重新写过了一个程序 #include <iostream> #include <malloc.h> #in ...

  5. hdu 1165 Eddy&#39;s research II(数学题,递推)

    // Eddy 继续 Problem Description As is known, Ackermann function plays an important role in the sphere ...

  6. HDU-1164-Eddy's research I(分解质因数)

    由于这道题目数据范围小,所以属于水题.可以采取暴力的做法来解决. 代码如下: #include"bits/stdc++.h" using namespace std; ; ]; v ...

  7. [hdu4497]分解质因数

    题意:求满足gcd(x,y,z)=G,lcm(x,y,z)=L的x,y,z的解的个数. 大致思路:首先如果L % G != 0那么无解,否则令u = L / G,问题变为,gcd(r,s,t)=1,l ...

  8. java例题_04 分解质因数

    1 /*4 [程序 4 分解质因数] 2 题目:将一个大于 2 正整数分解质因数.例如:输入 3, 3=3, 输入 6, 6=2*3,输入 90, 90=2*3*3*5. 3 程序分析:对 n 进行分 ...

  9. java分解质因数

      package test; import java.util.Scanner; public class Test19 { /** * 分析:对n进行分解质因数,应先找到一个最小的质数k * 最小 ...

  10. 程序设计入门——C语言 第6周编程练习 1 分解质因数(5分)

    1 分解质因数(5分) 题目内容: 每个非素数(合数)都可以写成几个素数(也可称为质数)相乘的形式,这几个素数就都叫做这个合数的质因数.比如,6可以被分解为2x3,而24可以被分解为2x2x2x3. ...

随机推荐

  1. 2015 Multi-University Training Contest 1 Tricks Device

    Tricks Device Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Tot ...

  2. @SpringBootApplication cannot be resolved to a type In STS

    @SpringBootApplication cannot be resolved to a type In STS 学习了:https://stackoverflow.com/questions/4 ...

  3. 我的Android进阶之旅------&gt;怎样将Activity变为半透明的对话框?

    我的Android进阶之旅------>怎样将Activity变为半透明的对话框?能够从两个方面来考虑:对话框和半透明. 在定义Activity时指定Theme.Dialog主题就能够将Acti ...

  4. LoadRunner使用入门 进行Webservice负载測试

    1.什么是LoadRunner LoadRunner是HP公司的一款付费工具,该工具是一种预測系统行为和性能的负载測试工具. 通过模拟上千万用户实施并发负载来确认和查找问题. 2.什么是负载測试 通过 ...

  5. Android Studio生成apk

    1.菜单Build->Generate Signed APK 2.生成android.keystore,能够依据弹框去Create new一个,也可使用命令来生成android.keystore ...

  6. Android微信智能心跳方案 Android微信智能心跳方案

    原文地址: http://mp.weixin.qq.com/s?__biz=MzAwNDY1ODY2OQ==&mid=207243549&idx=1&sn=4ebe4beb81 ...

  7. php7-swoole-Class 'swoole_websocket_server' not found 问题

    标签(空格分隔): php 分析 nginx/apache 读取的php.uini 文件 和 cli模式的php.ini 文件不同导致的 swoole是在cli模式下运行的 或许你安装swoole扩展 ...

  8. tomcat:Could not publish to the server. java.lang.IndexOutOfBoundsException

    1.将工程加入到tomcat,报上述错误 2. run--maven build 报jar包错误: invalid LOC header (bad signature) 3.根据提示找到上述jar包, ...

  9. B-Boxes

    http://agc010.contest.atcoder.jp/tasks/agc010_b Problem Statement There are N boxes arranged in a ci ...

  10. 使用HANDLECOLLISIONS的几个场景

    使用HANDLECOLLISIONS的几个场景: 1.target丢失delete记录(missing delete),忽略该问题并不记录到discardfile 2.target丢失update记录 ...