Eddy's research I

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 5050    Accepted Submission(s): 3027

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
两种做法:
代码:
 #include<iostream>
using namespace std;
const int maxn=;
int arr[maxn]={,,,};
void prime()
{
bool flag;
int k=;
for(int i=;i<maxn;i++)
{
flag=true;
for(int j=;j*j<=i;j++)
{
if(i%j==)
{
flag=false;
}
}
if(flag)arr[k++]=i;
}
}
int main()
{
int n,count;
prime();
while(cin>>n)
{
count=;
while(n!=)
{
for(int i=;n!=;i++)
{
if(n%arr[i]==)
{
if(count++==)
cout<<arr[i];
else
cout<<"*"<<arr[i];
n/=arr[i];
break;
}
}
}
cout<<endl;
}
return ;
}

代码:

 #include<stdio.h>
void show(int a)
{
int i=,n=;
while(i<=a&&a!=)
{
i++;
while(a%i==)
{
a/=i; n+=;
printf(n==?"%d":"*%d",i);
} }
puts(""); }
int main()
{
int x;
while(scanf("%d",&x)!=EOF)
show(x);
return ;
}

HDUOJ----Eddy's research I的更多相关文章

  1. Eddy's research I

    Eddy's research I Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others ...

  2. HDU 1165 Eddy's research II(给出递归公式,然后找规律)

    - Eddy's research II Time Limit:2000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64 ...

  3. hdu 1164:Eddy's research I(水题,数学题,筛法)

    Eddy's research I Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others ...

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

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

  5. HDOJ 1164 Eddy's research I

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

  6. HDU 1165 Eddy's research II (找规律)

    题意:给定一个表达式,然后让你求表达式的值. 析:多写几个就会发现规律. 代码如下: #pragma comment(linker, "/STACK:1024000000,102400000 ...

  7. HDU 1165 Eddy's research II

    题意:已知,求A(m, n). 分析:根据样例模拟一下过程就可以找出递推关系. #include<cstdio> #include<cstring> #include<c ...

  8. HDU 1164 Eddy's research I

    题目链接 题意 : 给你一个数,让你用它的素数质因子表示出来. 思路 : 先打一下表,因为会有重复的质因子,所以从大到小开始找,并且找到一个之后不能就接着往下找,要再找一遍这个数. #include ...

  9. 动态规划入门——Eddy's research II

    转载请注明出处:http://blog.csdn.net/a1dark 分析:找规律 #include<stdio.h> int main(){ int m,n; while(scanf( ...

  10. hdu 1164 Eddy's research I

    http://acm.hdu.edu.cn/showproblem.php?pid=1164 题意很简单,只是写代码的时候需要注意几个问题 一.筛选素数的时候记得用埃式筛选法,要是直接找可能会WA. ...

随机推荐

  1. Informatica 常用组件Lookup之二 已连接和未连接的查找

    可以配置一个已连接的查找转换,以从映射管道中直接接收输入:您也可以配置一个未连接的查找转换,以从其它转换的表达式结果中接收输入. 已连接的查找 未连接的查找 直接从管道接收输入值. 从其它转换的 :L ...

  2. mysql必知必会(三、使用mysql)

    一.连接mysql数据库 mysql -u 用户名 -p回车输入密码 二.显示所有的数据库 show databases; 三.使用数据库 use 数据库名; 四.显示所有的表 show tables ...

  3. 用VLC读取摄像头产生RTSP流,DSS主动取流转发(一)(二) 【转】

    http://blog.csdn.net/fm0517/article/details/38110633 http://blog.csdn.net/fm0517/article/details/381 ...

  4. IOS Key-Value Observing (KVO)

    kvo,与观察者模式类似,通过给指定的对象设置观察者,来检测对象的变化,当指定的对象的属性被修改后,用于作为观察者的对象会接收到通知.简单的说就是每次指定的被观察的对象的属性被修改后,kvo就会自动通 ...

  5. C++设计模式实现--模板(Template)模式

    一. 问题 在面向对象系统的分析与设计过程中常常会遇到这样一种情况:对于某一个业务逻辑(算法实现)在不同的对象中有不同的细节实现,可是逻辑(算法)的框架(或通用的应用算法)是同样的.Template提 ...

  6. OpenFace库(Tadas Baltrusaitis)中基于Haar Cascade Classifiers进行人脸检測的測试代码

    Tadas Baltrusaitis的OpenFace是一个开源的面部行为分析工具.它的源代码能够从 https://github.com/TadasBaltrusaitis/OpenFace 下载. ...

  7. lua接收图片并进行md5处理

    需要luacurl(http://luacurl.luaforge.net/)和MD5两个库函数 curl = require("luacurl") require("m ...

  8. C++:fread、fwrite函数用法

    主要内容: fread.fwrite函数的用法 1.函数功能 用来读写一个数据块. 2.一般调用形式 fread(buffer,size,count,fp); fwrite(buffer,size,c ...

  9. 【C#】C#委托学习

    虽然做.NET这行也快2年了,但基础不太好啊,今天看了下委托方面的知识,记录下. 1.委托 总的来说,委托是一个类,它定义了方法的类型,使得可以将方法当作另一个方法的参数来进行传递,这种将方法动态地赋 ...

  10. Python-__builtin__与__builtins__的区别与关系(超详细,经典)(转)

    Python-__builtin__与__builtins__的区别与关系(超详细,经典) (2013-07-23 15:27:32) 转载▼   分类: Python 在学习Python时,很多人会 ...