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. eclipse oracle Database Manager plugin oracle数据库连接插件

    在eclipseIDE中开发项目需要经常连接oracle数据库,装一些oracle client 去连接数据库,界面来回切换比较麻烦,所以专门找了一个eclipse插件专门连接oracle,跟大家分享 ...

  2. Linux获取当前时间

    代码(可以把clock_gettime换成time(NULL)) void getNowTime() { timespec time; clock_gettime(CLOCK_REALTIME, &a ...

  3. go语言基础之指针做函数参数

    1.指针做函数参数 示例: package main //必须有个main包 import "fmt" func swap(a, b int) { a, b = b, a fmt. ...

  4. Python的知识点 plt.plot()函数细节

    1.plt.plot(x,y,format_string,**kwargs) 转自点击打开链接x轴数据,y轴数据,format_string控制曲线的格式字串 format_string 由颜色字符, ...

  5. svn报错can only be performed on a version resource [at this time].

    报错 can only be performed on a version resource [at this time].   有的文件能提交,有的文件不能提交 猜想:是不是因为缓存问题方法:tea ...

  6. Linux下删除相互依赖的包

    今天遇到一个问题,使用RPM 卸载包的时候两个包相互依赖 包A 和包B 卸载A的时候提示需要先卸载B ,反之亦然 经过一番百度 可以在命令后面加参数--nodeps 例如 rpm -e php-jso ...

  7. 如何在Linux上面安装GCC 4.1.2

    安装步骤: 1.首先下载GCC 4.1.2的source code package: $ wget http://mirrors.ustc.edu.cn/gnu/gcc/gcc-4.1.2/gcc-4 ...

  8. Android 如何去掉手机中横竖屏切换时的转屏动画?

    前言          欢迎大家我分享和推荐好用的代码段~~ 声明          欢迎转载,但请保留文章原始出处:          CSDN:http://www.csdn.net        ...

  9. ListView.MouseDoubleClick

    private void ruleListView_MouseDoubleClick(object sender, MouseButtonEventArgs e) { ListViewItem ite ...

  10. [Javascript] Coding interview problem: Scheduler functional way

    Implement a job scheduler which takes in a function f and an integer n, and calls f after nmilliseco ...