[暖手][学习阶段-各路杂题][HDU-1164]Eddy's research I
来源:互联网 发布:js实现点击播放音乐 编辑:程序博客网 时间:2024/05/18 02:27
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
119412
Sample Output
112*2*13*181
import java.util.Arrays;import java.util.Scanner;public class Main { public static boolean judge(int n ){int i;for(i=2;i<=Math.sqrt(n)+1;i++)if(n%i==0)return false;return true;} public static void main(String args[]) { Scanner in = new Scanner(System.in); int[] num = new int[6542]; num[0]=2; for(int i=3, j=1;i<=65535;i++) if(judge(i)) {num[j]=i;j++;} while(in.hasNext()){ int n = in.nextInt(); boolean first = true; if(judge(n)) {System.out.println(n);continue;} while(!judge(n)){ for(int i =0;i<6542;i++) if(n%num[i]==0) {n/=num[i]; if(first){System.out.print(num[i]);first=false;} else System.out.print("*"+num[i]); break;} } System.out.println("*"+n); } } }
0 0
- [暖手][学习阶段-各路杂题][HDU-1164]Eddy's research I
- [暖手][学习阶段-各路杂题][HDU-1163]Eddy's digital Roots
- [暖手][学习阶段-各路杂题][HDU-1157]Who's in the Middle
- [暖手][学习阶段-各路杂题][HDU-1008]Elevator
- [暖手][学习阶段-各路杂题][HDU-1020]Encoding
- [暖手][学习阶段-各路杂题][HDU-1106]排序
- [暖手][学习阶段-各路杂题][HDU-1070]Milk
- [暖手][学习阶段-各路杂题][HDU-1164]Beat the Spread!
- 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 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
- 【技巧】 - 关于计算某个月有多少天 - 黑马程序员
- (一)Android布局之线性布局(LinearLayout)
- 放hi考试院苦苦与图看的图样
- 多线程程序为了调试方便应该多输出参数
- 遗传算法步骤以及编码
- [暖手][学习阶段-各路杂题][HDU-1164]Eddy's research I
- Ubuntu下BCM4313网卡驱动安装
- NYOJ 255 C小加 之 随机数
- UVa 10004 二染色
- 男人成功必备十条!
- 10405 - Longest Common Subsequence
- Android中Application实现数据共享
- 许嵩励志歌曲《浅唱》
- java对redis的基本操作