思路:将输入的这个数分成n个素数的相乘的结果,用一个数组存储起来。之后再输出就能够了

Eddy's research I

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

Total Submission(s): 6633    Accepted Submission(s): 3971
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
 

#include<stdio.h>
#include<string.h>
int a[55];
int getprime(int x)
{
memset(a,0,sizeof(a));
int i,cnt=0;
for(i=2; i<=x; i++)
{
while(x%i==0)
{
a[cnt++]=i;
x=x/i;
}
}
return cnt;
}
int main()
{
int n;
while(~scanf("%d",&n))
{
int k,i;
k=getprime(n);
for(i=0; i<k-1; i++)
printf("%d*",a[i]);
printf("%d\n",a[k-1]); }
return 0;
}

HDU 1164 Eddy&#39;s research I【素数筛选法】的更多相关文章

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

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

  2. HDU 2161 Primes (素数筛选法)

    题意:输入一个数判断是不是素数,并规定2不是素数. 析:一看就很简单吧,用素数筛选法,注意的是结束条件是n<0,一开始被坑了... 不说了,直接上代码: #include <iostrea ...

  3. POJ 3978 Primes(素数筛选法)

    题目 简单的计算A,B之间有多少个素数 只是测试数据有是负的 //AC //A和B之间有多少个素数 //数据可能有负的!!! #include<string.h> #include< ...

  4. POJ 2689 Prime Distance (素数筛选法,大区间筛选)

    题意:给出一个区间[L,U],找出区间里相邻的距离最近的两个素数和距离最远的两个素数. 用素数筛选法.所有小于U的数,如果是合数,必定是某个因子(2到sqrt(U)间的素数)的倍数.由于sqrt(U) ...

  5. LightOJ 1259 Goldbach`s Conjecture (哥德巴赫猜想 + 素数筛选法)

    http://lightoj.com/volume_showproblem.php?problem=1259 题目大意:给你一个数n,这个数能分成两个素数a.b,n = a + b且a<=b,问 ...

  6. poj 2262 Goldbach's Conjecture(素数筛选法)

    http://poj.org/problem?id=2262 Goldbach's Conjecture Time Limit: 1000MS   Memory Limit: 65536K Total ...

  7. HDU_2136——最大质因数,素数筛选法

    Problem Description Everybody knows any number can be combined by the prime number. Now, your task i ...

  8. 51nod 1536不一样的猜数游戏 思路:O(n)素数筛选法。同Codeforces 576A Vasya and Petya's Game。

    废话不多说,先上题目. 51nod Codeforces 两个其实是一个意思,看51nod题目就讲的很清楚了,题意不再赘述. 直接讲我的分析过程:刚开始拿到手有点蒙蔽,看起来很难,然后......然后 ...

  9. PAT甲题题解-1059. Prime Factors (25)-素数筛选法

    用素数筛选法即可. 范围long int,其实大小范围和int一样,一开始以为是指long long,想这就麻烦了该怎么弄. 而现在其实就是int的范围,那难度档次就不一样了,瞬间变成水题一枚,因为i ...

随机推荐

  1. Spark Sreaming与MLlib机器学习

    Spark Sreaming与MLlib机器学习 本来这篇是准备5.15更的,但是上周一直在忙签证和工作的事,没时间就推迟了,现在终于有时间来写写Learning Spark最后一部分内容了. 第10 ...

  2. 14.9 InnoDB Row Storage and Row Formats InnoDB 行存储和行格式:

    14.9 InnoDB Row Storage and Row Formats InnoDB 行存储和行格式: 14.9.1 Overview of InnoDB Row Storage 14.9.2 ...

  3. HDU1584:蜘蛛牌(DFS)

    Problem Description 蜘蛛牌是windows xp操作系统自带的一款纸牌游戏,游戏规则是这样的:只能将牌拖到比她大一的牌上面(A最小,K最大),如果拖动的牌上有按顺序排好的牌时,那么 ...

  4. 熬之滴水穿石:JSP--HTML中的JAVA代码(6)

                                                                       39--JSTL 在JSP编码中需考虑的一种方法,因为这种方法可以 ...

  5. 【Demo 0005】视图控制器

    本章学习要点:       1.  熟悉MVC模型及模型中(Modal, View, Control)用途:       2.  了解iOS中常见的几种视图控制器及使用场景:       3.  掌握 ...

  6. Tomcat 配置WEB虚拟映射 及 配置虚拟主机

    Tomcat  配置WEB虚拟映射 及 配置虚拟主机 配置WEB虚拟映射文件夹有三种方法例如以下: 第一(要重新启动server的): 打开路径 Tomcat 6.0\conf 下的 server.x ...

  7. java中int,float,long,double取值范围,内存泄露

    java中int,float,long,double取值范围是多少? 写道 public class TestOutOfBound { public static void main(String[] ...

  8. poj3468 A Simple Problem with Integers(线段树模板 功能:区间增减,区间求和)

    转载请注明出处:http://blog.csdn.net/u012860063 Description You have N integers, A1, A2, ... , AN. You need ...

  9. 【C++版】Face Alignment at 3000 FPS by Regressing Local Binary Features源码下载

    下载地址: 本帖隐藏的内容 <ignore_js_op> face-alignment-in-3000fps-master.zip (794.42 KB, 下载次数: 1076) 该源码采 ...

  10. JAVA WEB开发环境搭建教程

    一.下载安装JDK,配置好环境变量.(例如我JDK安装的目录为:C:\Program Files (x86)\Java\jdk1.6.0_10     ) 点击我的电脑-属性-系统设置(高级系统设置) ...