HDU 1405 The Last Practice
The Last Practice
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 9226 Accepted Submission(s): 1960
We
have been training for 45 days, and all guys must be tired.But , you
are so lucky comparing with many excellent boys who have no chance to
attend the Province-Final.
Now, your task is relaxing yourself
and making the last practice. I guess that at least there are 2 problems
which are easier than this problem.
what does this problem describe?
Give you a positive integer, please split it to some prime numbers, and you can got it through sample input and sample output.
file contains multiple test case, each case consists of a positive
integer n(1<n<65536), one per line. a negative terminates the
input, and it should not to be processed.
each test case you should output its factor as sample output (prime
factor must come forth ascending ), there is a blank line between
outputs.
60=2^2*3^1*5^1
#include <cstdio> int main()
{
int n,cn = ;
while(scanf("%d",&n), n>){
if(cn != )
printf("\n");
printf("Case %d.\n",++cn);
for(int i = ; i*i <= n; ++i){
int cnt = ;
while(n%i == ){
++cnt;
n /= i;
}
if(cnt != )
printf("%d %d ",i,cnt);
}
if(n>)
printf("%d 1 ",n);
printf("\n");
}
return ;
}
HDU 1405 The Last Practice的更多相关文章
- HDU 1405 The Last Practice 数学水题
http://acm.hdu.edu.cn/showproblem.php?pid=1405 题目大意: 给你一个数,让你分解素因子,输出它的各次幂. 如60 输出:2 2 3 1 5 1 (60=2 ...
- HDU 1405 第六周 J题
Description Tomorrow is contest day, Are you all ready? We have been training for 45 days, and all ...
- hdoj 1405 The Last Practice
The Last Practice Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others ...
- HDU 1405
题意: 输入一个数n,输出它的素因子与这个素因子出现的次数. 分析: 用欧拉函数,变下形就好了,不再过多解释. 代码如下: #include <iostream> #include < ...
- hdu 1096 A+B for Input-Output Practice (VIII)
A+B for Input-Output Practice (VIII) Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/3 ...
- hdu 1095 A+B for Input-Output Practice (VII)
A+B for Input-Output Practice (VII) Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32 ...
- hdu 1094 A+B for Input-Output Practice (VI)
A+B for Input-Output Practice (VI) Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/327 ...
- hdu 1093 A+B for Input-Output Practice (V)
A+B for Input-Output Practice (V) Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/3276 ...
- hdu 1092 A+B for Input-Output Practice (IV)
A+B for Input-Output Practice (IV) Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/327 ...
随机推荐
- sql之解决数据库表的循环依赖问题
三张数据表关系如图: 其实出现表循环依赖情况:就是 同时 ConfigCompany和 Department 也有依赖,就会报错,说有循环依赖,就会报错. 所以 这个时候的解决办法:可以改 在数据库 ...
- (转)关于ARM9协处理器CP15及MCR和MRC指令
网址:http://blog.csdn.net/zhou1232006/article/details/6150198 在基于ARM的嵌入式应用系统中,存储系统通常是通过系统控制协处理器CP15完成的 ...
- 你不需要jQuery(五)
什么不用jQuery?因为它让你的网站体积变得臃肿.你的网站并不真的需要jQuery,不需要它带来的额外体积.带宽和加载时间. 用原生JavaScript简单实现jQuery提供的功能和方法 查找.选 ...
- dijkstra,bellman-ford,floyd分析比较
http://www.cnblogs.com/mengxm-lincf/archive/2012/02/11/2346288.html 其实我一直存在疑惑是什么导致dijkstra不能处理负权图? 今 ...
- Discuz云平台站点信息同步失败,An unknown error occurred. May be DNS Error.
站点信息同步失败 An unknown error occurred. May be DNS Error. (ERRCODE:1) 经过Discuz教程网(http://www.1314study.c ...
- 【转】Java自动装箱、拆箱、缓冲池
JDK5以后 Integer a = 3; 这是自动装箱int i = new Integer(2); 这是自动拆箱就是基本类型和其对应的包装类型在需要的时候可以互相 ...
- php关于private、public成员变量访问问题
如果类里面定义了__get($name)方法,则不论类的private成员还是public成员,都能够在类的外面通过类似$class->name访问到.如果是public变量,则不会自动调用ge ...
- MyEclipse server窗口 Could not create the view: An unexpected exception was thrown 错误解决
MyEclipse 打开后有时候莫名的在server窗口里抛出“Could not create the view: An unexpected exception was thrown”错误,解决办 ...
- 多线程 (四)GCD
学习GCD要掌握几个概念 任务:需要执行的代码块可以看作一个任务 队列:把任务放到队列里,遵循先进先出的原则 队列又分为串行队列和并行队列 串行队列:顺序执行 并发队列:同时执行多个任务 同步:在当前 ...
- cocos2d-html5 onEnter init ctor构造函数 ----js特有特性(和c++有一点不一样)
ctor 构造函数, new 一个对象的时候调用-----coco2d-js , 默认ctor,为对象的构造函数,其它也可以默认其它函数为构造函数. 说白了就是: ctor构造函数 new 对象后自动 ...