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. ubuntu find方法

    通用格式:find pathname -options [-print -exec -ok]例子:find / -name filename 再根目录里面搜索文件名为filename的文件find / ...

  2. mysql 权限管理

     参考:    http://www.cnblogs.com/Richardzhu/p/3318595.html 一.MySQL权限简介 关于mysql的权限简单的理解就是mysql允许你做你全力以内 ...

  3. mybatis--面向接口编程

    如果使用hiberante作为dao层,常用的方式是:定义一个dao层接口包(com.dao.service)然后在定义一个dao层接口实现包(com.dao.service.impl),这样定义结构 ...

  4. jquery判断对象是否获得焦点

    var isFocus=$("#tRow").is(":focus"); if(true==isFocus){ alert("focus") ...

  5. 详细解析: VictorOps 是如何利用和完善 ChatOps?

    ChatOps,即聊天应用,在软件开发中被广泛应用改进开发者之间的沟通.简单地说,ChatOps 是将内容或行动 (或两者) 迁移到聊天客户端.这样做之后,企业内的所有团队都能分享重要信息,行动,及其 ...

  6. Unique Binary Search Trees II

    Given n, generate all structurally unique BST's (binary search trees) that store values 1...n. For e ...

  7. CF 136B Ternary Logic

    http://codeforces.com/problemset/problem/136/B 题意 :就是说tor是一个三进制的运算,代表的是两个三进制数的运算,两个三进制数按位逐一相加后对三取余,没 ...

  8. MyEclipse server窗口 Could not create the view: An unexpected exception was thrown 错误解决

    MyEclipse 打开后有时候莫名的在server窗口里抛出“Could not create the view: An unexpected exception was thrown”错误,解决办 ...

  9. SaaS系列介绍之二: SaaS介绍

    1 引言 横看成岭侧成峰,远近高低各不同. 不识庐山真面目, 只缘身在此山中.                                                  ________苏轼, ...

  10. CentOS笔记——配置DNS服务器

    前话 咳咳,这次Linux系统的DNS服务器搭建我不得不记下来.,这错误真的太蛋疼了,我整整弄了两天才解决问题(抱歉我很蠢). 也许有人会和我犯同样的错误,给大家分享一下经验. 首先总结一下知识点: ...