HDU——1405The Last Practice(试手map)
2016-02-15 22:11
232 查看
The Last Practice
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 9185 Accepted Submission(s): 1947
[align=left]Problem Description[/align]
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.
[align=left]Input[/align]
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.
[align=left]Output[/align]
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.
[align=left]Sample Input[/align]
60 12 -1
[align=left]Sample Output[/align]
Case 1. 2 2 3 1 5 1 Case 2. 2 2 3 1 Hint 60=2^2*3^1*5^1
本地编译器优化的太多也不好,一个语句分号前面多了个逗号竟然也可以编译,第一次妥妥的CE了
代码:
#include<iostream> #include<cstdio> #include<algorithm> #include<map> #include<set> using namespace std; int main(void) { int n,i,t=0; while (cin>>n&&n>=0) { t++; if(t!=1) cout<<endl; map<int,int> list; for (i=2; i<=n; i++) { while (n%i==0) { list[i]++; n/=i; } } map<int,int>::iterator it; printf("Case %d.\n",t); for (it=list.begin(); it!=list.end(); it++) { cout<<it->first<<" "<<it->second<<" ";//这题有毒竟然不按套路出牌,最后也要有空格 } cout<<endl; } return 0; }
相关文章推荐
- struts2学习笔记--上传单个和批量文件示例
- 解读分库分表中间件Sharding-JDBC
- Android中的Bitmap的高效加载介绍
- linux环境变量和本地变量
- 方块填数
- ANDROID_MARS学习笔记_S01原始版_012_广播机制一
- Android-Adb-连接海马玩模拟器
- 对Python内存管理的认识(重点usedpool的一个trick的理解)http://blog.csdn.net/wangyuquanliuli/article/details/8606072
- 结构体内部的偏移
- 从头认识Spring-2.4 基于java的标准注解装配-@Inject(3)-通过构造器方法注入
- WF4.0与多线程
- hdu acm 1532 Drainage Ditches
- JDBC简单实用总结
- AsyncDisplayKit
- hdu2795 Billboard (机智的线段树点更新)
- 原生态JAVAEE酒店管理系统系列一 之编码之前的环境准备
- 六种常用的设计模式java实现(一)工厂模式
- hdu 1029 Ignatius and the Princess IV
- Android杂谈之获取sdcard信息
- Match:DNA repair(POJ 3691)