YJC tricks time
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 524288/262144 K (Java/Others)Total Submission(s): 731 Accepted Submission(s): 322
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 .
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 12000∗180=2160000 .
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 12000∗180=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)
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
题意:
YJC收到了一份神秘礼物。是一个长成这样的钟。
YJC不是时间领主所以他并不能乱搞时间,但是这个钟实在是太难认了!所以他想来耍耍你。
现在YJC给你时针和分针间的夹角,让你告诉他现在是什么时候。
你将以以下格式给出可能的时间:
HH:MM:SS
分别表示小时,分钟,秒(比如:08:30:20)在这里使用12小时制,也就是说时间范围是从00:00:00到11:59:59
另外,YJC不想要太精确的时间,所以当且仅当SS mod 10 = 0,答案才合法。
思路:直接暴力枚举就好了。
ac代码:
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stack>
#include<set>
#include<queue>
#include<vector>
#define MAXN 1010000
#define LL long long
#define ll __int64
#include<iostream>
#include<algorithm>
#define INF 0xfffffff
#define mem(x) memset(x,0,sizeof(x))
#define PI acos(-1)
using namespace std;
LL gcd(LL a,LL b){return b?gcd(b,a%b):a;}
LL lcm(LL a,LL b){return a/gcd(a,b)*b;}
LL powmod(LL a,LL b,LL MOD){LL ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}
//head
int main()
{
int n;
while(scanf("%d",&n)!=EOF)
{
int i,j,k;
for(i=0;i<12;i++)
{
for(j=0;j<60;j++)
{
for(k=0;k<60;k+=10)
{
int a=360000*i+6000*j+100*k;
int b=72000*j+1200*k;
int c=a-b;
int t=360*12000;
while(c>=t)
c-=t;
while(c<0)
c+=t;
if(c>t/2)
c=t-c;
if(c==n)
printf("%02d:%02d:%02d\n",i,j,k);
}
}
}
}
return 0;
}