思路:将输入的这个数分成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. 转载【浅谈ThreadPool 线程池】

    浅谈ThreadPool 线程池 http://www.cnblogs.com/xugang/archive/2010/04/20/1716042.html

  2. DirectX SDK版本与Visual Studio版本

    对于刚刚接触 DirectShow 的人来说,安装配置是一个令人头疼的问题,经常出现的情况是最基本的 baseclass 就无法编译.一开始我也为此费了很大的功夫,比如说修改代码.修改编译选项使其编译 ...

  3. 一个完善的ActiveX Web控件教程

    免费打工仔:一个完善的ActiveX Web控件教程 出自Ogre3D开放资源地带   跳转到: 导航, 搜索 原作者 David Marcionek. 翻译 免费打工仔 这个教程可以帮助你快速开发一 ...

  4. [置顶] 关于redhat系统yum源的配置2

    (二)配置yum源(官方) 1.在终端输入以下命令(RHEL6/CentOS6) wget http://lug.ustc.edu.cn/wiki/_export/code/mirrors/help/ ...

  5. 给你的站点加入 console.js

    本文仅先给使用console调试的FE同学,假设你还不知道console是什么.或者还停留在alert阶段,那就不要浪费时间了,say bay bay! 你是否试程序的过程中用过console.log ...

  6. ibatis新手入门

    ibatis 是什么 iBATIS是以SQL为中心的持久化层框架. 能支持懒载入.关联查询.继承等特性. iBATIS不同于一般的OR映射框架. OR映射框架,将数据库表.字段等映射到类.属性,那是一 ...

  7. 对TMemoryStream的一些改进(用到了LockFile)

    对TMemoryStream的一些改进 怎么又是关于Stream的,呵呵,应该说只是最近比较关心程序的效率问题,而我对Stream其实并没有什么特别的研究,只是自己发现了一些新的用法,希望能对大家有用 ...

  8. 单例模式(Singleton)Holder

    public class Singleton { /** * 类级的内部类,也就是静态的成员式内部类,该内部类的实例与外部类的实例 * 没有绑定关系,而且只有被调用到才会装载,从而实现了延迟加载 */ ...

  9. jquery 学习 (二)

    1)jquery对象和dom对象区别及相互转换 2)jquery和其他库冲突解决 3)css选择器和jquery选择器 3.1)基本选择器(id选择器.类选择器.元素选择器.*选择器.多个选择器以逗号 ...

  10. Delphi数据类型转换(有几个字符串函数没见过,比如StringToWideChar和WideCharToString)

    DateTimeToFileDate                  函数                     将DELPHI的日期格式转换为DOS的日期格式         DateTimeT ...