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

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

本地编译器优化的太多也不好,一个语句分号前面多了个逗号竟然也可以编译,第一次妥妥的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;
}

HDU——1405The Last Practice(试手map)的更多相关文章

  1. VK Cup 2016 - Qualification Round 1——B. Chat Order(试手stack+map)

    B. Chat Order time limit per test 3 seconds memory limit per test 256 megabytes input standard input ...

  2. HDU——1303Doubles(水题,试手二分查找)

    Doubles Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Su ...

  3. [HDU] 2094 产生冠军(拓扑排序+map)

    题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=2094 注意每组数据处理前,map要清空. #include<cstdio> #includ ...

  4. hdu 1263 水果 【二维map】

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1263 题目大意: Problem Description 夏天来了~~好开心啊,呵呵,好多好多水果~~ ...

  5. hdu 5012 bfs --- 慎用STL 比方MAP判重

    http://acm.hdu.edu.cn/showproblem.php?pid=5012 发现一个问题 假设Sting s = '1'+'2'+'3'; s!="123"!!! ...

  6. HDU - 3347 Calculate the expression — 模拟 + map存变量

    传送门 题意:从输入开始,1.输入样例数:2.然后输入一组样例中的行数n:3.前n-1行为定义变量(之间使用空格隔开),只需要map存进去就可以了(这里有覆盖的情况,故使用mp["s&quo ...

  7. hdu 1430 (BFS 康托展开 或 map )

    第一眼看到这题就直接BFS爆搜,第一发爆了内存,傻逼了忘标记了,然后就改,咋标记呢. 然后想到用map函数,就8!个不同的排列,换成字符串用map标记.然后又交一发果断超时,伤心,最恨超时,还不如来个 ...

  8. HDU 1004 Let the Balloon Rise map

    Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Oth ...

  9. HDU 1247 Hat’s Words(map,STL,字符处理,string运用)

    题目 用map写超便捷 也可以用字典树来写 我以前是用map的: #include<stdio.h> #include<string.h> #include<algori ...

随机推荐

  1. UVA 1608 Non-boring sequence 不无聊的序列(分治,中途相遇)

    题意:给你一个长度为n序列,如果这个任意连续子序列的中都有至少出现一次的元素,那么就称这个序列是不无聊的,判断这个序列是不是无聊的. 先预处理出每个元素之前和之后相同元素出现的位置,就可以在O(1)的 ...

  2. mangoDB笔记

    1.  查询 db.表.find().pretty() find(querry,project) pretty()格式化显示 findOne()  返回一条结果 比较 db.Decl_In.find( ...

  3. 使用ImageList组件制作动画图片

    实现效果: 知识运用: Timer组件的Enabled属性  Tick事件 PictureBox控件的Image属性 ImageList组件的Images属性 实现代码: private void F ...

  4. 2018.3.12 Leecode习题 给定一个整数数列,找出其中和为特定值的那两个数。

    给定一个整数数列,找出其中和为特定值的那两个数. 你可以假设每个输入都只会有一种答案,同样的元素不能被重用. 示例: 给定 nums = [2, 7, 11, 15], target = 9; 因为 ...

  5. Mac OS X El Capitan系统完整性保护System Integrity Protection (SIP)

    http://blog.csdn.net/yulimin/article/details/49992031 引言:前段时间经历了XCode编译器代码被注入的事件后,这次 Mac OS X El Cap ...

  6. OO作业第一单元总结

    一.第一单元作业回顾 ​ 系列一作业分为三周进行,都是表达式求导,难度渐进. ​ 第一次实现的是简单幂函数的求导,第二次加入了sin和cos两种三角函数,第三次实现了三角函数内的嵌套以及引入了表达式因 ...

  7. 洛谷 P5015 标题统计

    第一道题很简单,标签:字符串.模拟. 只需要一个判断去除空格就对了: if(a[i]!=' ' && a[i]!='\n') v++; code: #include<iostre ...

  8. NOIP2018 - 暑期博客整理

    暑假写的一些博客复习一遍.顺便再写一遍或者以现在的角度补充一点东西. 盛暑七月 初涉基环外向树dp&&bzoj1040: [ZJOI2008]骑士 比较经典的基环外向树dp.可以借鉴的 ...

  9. mysql 添加数据如果数据存在就更新ON DUPLICATE KEY UPDATE和REPLACE INTO

    #下面建立game表,设置name值为唯一索引. CREATE TABLE `game` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar( ...

  10. SSH框架面试总结----1

    1:struts2的工作流程 1)客户端浏览器发出HTTP请求. 2)根据web.xml配置,HTTP请求会被FilterDispatcher接收. 3)根据struts.xml,找到对应的Actio ...