HDOJ 5276 YJC tricks time multimap

原创 2015年07月10日 09:52:10


multimap的使用

YJC tricks time

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 524288/262144 K (Java/Others)
Total Submission(s): 492    Accepted Submission(s): 215


Problem Description
YJC received a mysterious present. It's a clock and it looks like this. 



YJC is not a timelord so he can't trick time but the clock is so hard to read. So he'd like to trick you.

Now YJC gives you the angle between the hour hand and the minute hand, you'll tell him what time it is now.

You'll give him the possible time in the format:

HH:MM:SS

HH represents hour, MM represents minute, SS represents second.
(For example, 08:30:20)

We use twelve hour system, which means the time range is from 00:00:00 to 11:59:59.

Also, YJC doesn't want to be too accurate, one answer is considered acceptable if and only if SS mod 10 = 0 .
 

Input
Multiple tests.There will be no more than 1000 cases in one test.
for each case:

One integer x indicating the angle, for convenience, x has been multiplied by 12000. (So you can read it as integer not float) In this case we use degree as the unit of the angle, and it's an inferior angle. Therefore, x will not exceed 12000180=2160000.
 

Output
For each case:

T lines. T represents the total number of answers of this case.

Output the possible answers in ascending order. (If you cannot find a legal answer, don't output anything in this case)
 

Sample Input
99000 0
 

Sample Output
00:01:30 11:58:30 00:00:00
 

Source
 

/* ***********************************************
Author        :CKboss
Created Time  :2015年07月10日 星期五 08时55分44秒
File Name     :HDOJ5276.cpp
************************************************ */

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;

struct Time
{
	int hh,mm,ss;
};

multimap<int,Time> mt;

/// every 10 second
/// s: 720000 m: 12000 h: 1000

const int DS=720000;
const int DM=12000;
const int DH=1000;
const int MOD=360*12000;

int degS=-DS,degM=-DM,degH=-DH;

int ADD()
{
	degS=(degS+DS)%MOD;
	degM=(degM+DM)%MOD;
	degH=(degH+DH)%MOD;

	int dur=abs(degM-degH);
	if(dur>MOD/2) dur=MOD-dur;

	return dur;
}

void init()
{
	for(int h=0;h<=11;h++)
	{
		for(int m=0;m<=59;m++)
		{
			for(int s=0;s<60;s+=10)
			{
				int t=ADD();
				mt.insert(make_pair(t,(Time){h,m,s}));
			}
		}
	}
}

int main()
{
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);

	init();
	int x;
	while(scanf("%d",&x)!=EOF)
	{
		multimap<int,Time>::iterator it;
		it=mt.find(x);
		int cnt=mt.count(x);
		for(int i=0;i<cnt;i++,it++)
		{
			Time time = it->second;
			printf("%02d:%02d:%02d\n",time.hh,time.mm,time.ss);
		}
	}
    
    return 0;
}



版权声明:来自: 码代码的猿猿的AC之路 http://blog.csdn.net/ck_boss

相关文章推荐

HDU 5276 YJC tricks time

Problem Description YJC received a mysterious present. It's a clock and it looks like this.  ...

YJC tricks time(钟表问题)

Link:http://acm.hdu.edu.cn/showproblem.php?pid=5276 YJC tricks time Time Limit: 2000/1000 ...

hdoj5276GCD

GCD Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Sub...

平面图最大团 HDOJ 5277 YJC counts stars

CF上也有类似题。。。。注意到题目中的是平面图,给出的点是没用的。。。平面图最大团点数只有1,2,3,4四种情况,分类计算一下就行了。。。 #include #include #include ...

HDOJ-5277 YJC counts stars(DFS)

不难发现,满足条件的点集大小不可能超过4,这样的话进行DFS的深度是很浅的。枚举第一个点,再枚举第二个点,如果第二个点与第一个点有边则继续枚举第三个点,判断是否和前两个点都有边,第四个点同理,并不断更...

【NTT】 HDOJ 5279 YJC plays Minecraft

推出公式以后就可以ntt了。。。 #include using namespace std; typedef long long LL; const int mod = 998244353; c...

100+ Google Tricks That Will Save You Time in School

转自:http://www.eternalcode.com/100-google-tricks-that-will-save-you-time-in-school With classes,...

hdu 5277 YJC counts stars(邻接表+构造)

题意: 给出n个点和m条边,题目保证任意两条边如果相交那么交点一定是两条线段的端点。定义dujiao点集为点集中任意两点均连成线段。求所有的dujiao点集中点的个数最大是多少个,并输出有多少个点...

hdu 5277 YJC counts stars

hdu 5277 YJC counts stars 题意: 给出一个平面图,n个点,m条边,直线边与直线边之间不相交,求最大团的数目。 限制: 1 思路: 由于平面图,直线边...
  • whai362
  • whai362
  • 2015年07月06日 10:47
  • 782
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:HDOJ 5276 YJC tricks time multimap
举报原因:
原因补充:

(最多只允许输入30个字)