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. [Mongo] 解决mongoose不支持条件操作符 $gt$gte:$lte$ne $in $all $not

    reference : http://blog.sina.com.cn/s/blog_4df23d840100u25x.html 找到mongoose的安装目录 /usr/local/lib/node ...

  2. cout的输出格式初探2

    #include <iostream> #include <iomanip> using namespace std; int main() { cout<<&qu ...

  3. C语言的32个保留字

    auto :声明自动变量 double :声明双精度变量或函数 int: 声明整型变量或函数 struct:声明结构体变量或函数 break:跳出当前循环 else :条件语句否定分支(与 if 连用 ...

  4. JavaScript的js文件压缩和格式化工具

    JavaScriptcompressor.com这个网站可是大名鼎鼎啊.以前在找到过压缩 Javascript 代码的程序,一直在用,感觉效果不错.域名是: http://javascriptcomp ...

  5. HBase数据迁移至Hive

    背景:需要将HBase中表xyz(列簇cf1,列val)迁移至Hive 1. 建立Hive和HBase的映射关系     1.1 运行hive shell进入hive命令行模式,运行如下脚本 CREA ...

  6. iPhone调用ffmpeg2.0.2解码h264视频的示例代码

    iPhone调用ffmpeg2.0.2解码h264视频的示例代码 h264demo.zip 关于怎么在MAC下编译iOS下的ffmpeg请看 编译最新ffmpeg2.0.1(ffmpeg2.0.2)到 ...

  7. MySQL Cluster线上管理节点配置文件-数据节点32G内存

    网上的朋友提供的,仅供参考. [NDBD DEFAULT] NoOfReplicas= 2 DataMemory=20G IndexMemory=5G MaxNoOfConcurrentTransac ...

  8. locate 命令(转)

    原文:http://www.cnblogs.com/peida/archive/2012/11/12/2765750.html locate 让使用者可以很快速的搜寻档案系统内是否有指定的档案.其方法 ...

  9. Linux对文件内容基本操作(学习笔记七)

    一.cat 1.1.查看文件内容 格式:cat 文件名 [root@model /]# cat /etc/resolv.conf # Generated by NetworkManager names ...

  10. STL 源代码剖析 算法 stl_algo.h -- partial_sort / partial_sort_copy

    本文为senlie原创,转载请保留此地址:http://blog.csdn.net/zhengsenlie partial_sort / partial_sort_copy ------------- ...