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

Problem Description
Tomorrow is contest day, Are you all ready?
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.

 
Input
Input
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.
 
Output
For
each test case you should output its factor as sample output (prime
factor must come forth ascending ), there is a blank line between
outputs.
 
Sample Input
60
12
-1
 
Sample Output
Case 1.
2 2 3 1 5 1
 
Case 2.
2 2 3 1

Hint

60=2^2*3^1*5^1

 
Author
lcy
 
Source
 
 
 
解析:给定一个正整数,将它分解为素数的乘积。
 
 
 
 #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的更多相关文章

  1. HDU 1405 The Last Practice 数学水题

    http://acm.hdu.edu.cn/showproblem.php?pid=1405 题目大意: 给你一个数,让你分解素因子,输出它的各次幂. 如60 输出:2 2 3 1 5 1 (60=2 ...

  2. HDU 1405 第六周 J题

    Description Tomorrow is contest day, Are you all ready?  We have been training for 45 days, and all ...

  3. hdoj 1405 The Last Practice

    The Last Practice Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others ...

  4. HDU 1405

    题意: 输入一个数n,输出它的素因子与这个素因子出现的次数. 分析: 用欧拉函数,变下形就好了,不再过多解释. 代码如下: #include <iostream> #include < ...

  5. 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 ...

  6. 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 ...

  7. 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 ...

  8. 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 ...

  9. 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 ...

随机推荐

  1. Objective-C程序结构及语法特点

    程序文件分为头文件(.h)和实现文件(.m): 使用#import关键字将所需的头文件导入程序,并且可以避免程序重复引用相同的头文件: @autoreleasepool { … } 自动释放池: 符号 ...

  2. 【POJ2104】kth num

    You are working for Macrohard company in data structures department. After failing your previous tas ...

  3. java中四种引用类型

    java中四种引用类型  今天看代码,里面有一个类java.lang.ref.SoftReference把小弟弄神了,试想一下,接触java已经有3年了哇,连lang包下面的类都不了解,怎么混.后来在 ...

  4. cmp比较指令对标志寄存器的影响

    比如: mov ax,x mov bx,y cmp ax,bx cmp ax,bx的逻辑含义是比较ax,bx中的值.如果执行后: ZF=1则AX=BX ZF=0则AX!=BX CF=1则AX<B ...

  5. [转载]获取当前日期和农历的js代码

    原文地址: http://www.cnblogs.com/Gnepner/archive/2011/09/07/2169822.html 获取当前日期时间: function GetCurrentDa ...

  6. Deep Learning and the Triumph of Empiricism

    Deep Learning and the Triumph of Empiricism By Zachary Chase Lipton, July 2015 Deep learning is now ...

  7. The 5th Zhejiang Provincial Collegiate Programming Contest---ProblemF:Faster, Higher, Stronger

    http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2970 唔...第二水题.除了Faster是输出最小外,另外两个都是输出最大 ...

  8. css3属性整理

    浏览器内核:主流内容主要有Mozilla(熟悉的有Firefox,Flock等浏览器).WebKit(熟悉的有Safari.Chrome等浏览器).Opera(Opera浏览器).Trident(讨厌 ...

  9. linux 修改命令行编码 乱码解决方案

    修改/etc/default/locale命令:sudo vim /etc/default/locale1将下面这两行 LANG=zh_CN.UTF-8 LANGUAGE=zh_CN:zh 修改为: ...

  10. Android中如何取消调转界面后EditText默认获取聚焦问题

    最近在做一个项目,当我点击跳转至一个带有EditText的界面后,模拟器中的软键盘会自动弹出,严重影响了用户体验.在网上找了资料,现总结如下. 我们知道,EditText有一个 android:foc ...