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. 安卓5.1/7.1/8.1+wifi有叉问题解决

    7.1/8.1 adb shell "settings put global captive_portal_http_url http://captive.v2ex.co/generate_ ...

  2. C错误异常处理,异常处理

    预处理器标识#error的目的是什么啊? 指令 用途 # 空指令,无任何效果 #include 包含一个源代码文件 #define 定义宏 #undef 取消已定义的宏 #if 如果给定条件为真,则编 ...

  3. 10 Big Data Possibilities for 2017 Based on Oracle's Predictions

    2017 will see a host of informed predictions, lower costs, and even business-centric gains, courtesy ...

  4. TRIZ理论的进化法则分析(TRIZ学习笔记)

    人们在创新和完好系统的过程能够遵循一定的规律(或者叫法则).从而降低创新和完好系统过程中的试错成本,以下就TRIZ的八大进化原则来进行说明(这个八大法则是前人们的总结,我这里当然会增加我的理解). 我 ...

  5. 第三章 mybatis-generator + mysql/ptsql

    用了mybatis-generator,我就不再想用注解了,这与我之前说的注解与XML并用是矛盾的,知识嘛,本来就是多元化的,今天喜欢这个,明天喜欢那个,哈哈,看了mybatis-generator下 ...

  6. Android中ActionBar及Overflow的显示

    最近在按照Android的API文档学习Android中actionbar的使用,Action bar 最基本的形式,就是为 activity 显示标题,并且在标题左边显示一个 app icon.在这 ...

  7. Spark性能优化(2)——广播变量、本地缓存目录、RDD操作、数据倾斜

    广播变量 背景 一般Task大小超过10K时(Spark官方建议是20K),需要考虑使用广播变量进行优化.大表小表Join,小表使用广播的方式,减少Join操作. 参考:Spark广播变量与累加器 L ...

  8. 【系统】supervisor支持多进程

    [program:deployworker] directory = /etc/ansible/easyAnsible/app/deploy/ command = python Deploy.py p ...

  9. CentOS 7上安装WordPress详细步骤

    一.搭建Wordpress服务器环境需求: php 5.2.4 或者更高版本.MySQL 5.0 或者更高版本. 二.搭建Wordpress平台:以下以Wordpress3.92版本为例进行说明,如果 ...

  10. (转)Unity3d UnityEditor编辑器定制和开发插件

    在阅读本教程之前,你需要对Unity的操作流程有一些基础的认识,并且最好了解内置的GUI系统如何使用. 如何让编辑器运行你的代码 Unity3D可以通过事件触发来执行你的编辑器代码,但是我们需要一些编 ...