思路:将输入的这个数分成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. [SVN] 分支同步、合入主干操作分享

    冲突的解决原则 不是自己修改的地方就使用主干的. 需要特别注意的是: 分支同步主干时,远端(theirs)是主干,本地(mine/working)的是分支: 分支合入主干时,本地(mine/worki ...

  2. 如何使用Gmail的别名功能?

    Gmail真的是一个很好的邮箱,一直是我的最爱!它有一个很独特的功能-别名,用这个功能,我们就可以把一个 邮箱当成很多个邮箱来使用了! 1.Gmail 不提供传统别名 ,但是你可以收到发送到 your ...

  3. session对象和applicatione对象

    ASP.NET 的常用对象有:response对象.request对象.application对象.server对象.session对象.下面主要讨论session对象和cookie对象. sessi ...

  4. hdu 4455 Substrings (DP 预处理思路)

    Substrings Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Tota ...

  5. UML基本架构建模--类概述

     Classes 类 Classes are the most important building block of any object-oriented system. A class is ...

  6. [Java 8] (6) Lambda与资源管理

    资源处理 Java本身自带了垃圾回收(Garbage Collection)功能.可是仅仅有垃圾回收的目标是内部资源(Internal Resource),典型的比方堆上分配的内存区域等.对于外部资源 ...

  7. Swift - 炫酷放射弹出按钮菜单(改造自AwesomeMenu)

    这个是一个第三方按钮菜单组件,原版是使用Objective-C编写的名为AwesomeMenu的组件,地址是:https://github.com/levey/AwesomeMenu 这里改造成了Sw ...

  8. 经典的C++库【转帖】

    源地址:http://www.deuxmille.org/archives/1472 基础类1. Dinkumware C++ Library 参考站点:http://www.dinkumware.c ...

  9. leetcode第一刷_Largest Rectangle in Histogram

    非常难的问题,数组线性时间. 属于我之前说的解法的借助辅助空间.给定两个柱子,他们之间的面积由什么确定呢?没错,他们之间的距离和他们之间最矮的那个柱子的高度.我们并不知道这个柱子在什么位置,所以仅仅能 ...

  10. [Android学习笔记]Android Library Project的使用

    RT http://developer.android.com/tools/projects/index.html