hdu 5276 YJC tricks time 数学

YJC tricks time

Time Limit: 20 Sec

Memory Limit: 256 MB

题目连接

http://acm.hdu.edu.cn/showproblem.php?pid=5276

Description

YJC收到了一份神秘礼物。是一个长成这样的钟。


YJC不是时间领主所以他并不能乱搞时间,但是这个钟实在是太难认了!所以他想来耍耍你。

现在YJC给你时针和分针间的夹角,让你告诉他现在是什么时候。

你将以以下格式给出可能的时间:
HH:MM:SS
分别表示小时,分钟,秒(比如:08:30:20)在这里使用12小时制,也就是说时间范围是从00:00:00到11:59:59

另外,YJC不想要太精确的时间,所以当且仅当SS mod 10 = 0,答案才合法。

Input

多组数据,数据组数 ≤1000。
对于每组数据每行输入一个整数x表示角度,为了方便x乘了12000(这样你就不用使用浮点型读入而可以使用整数)。在这题里我们使用角度制。角度按成的劣角算。所以x不会超过 12000∗180=2160000。

Output

对于每组数据:
输出T行。T表示这组数据答案总数。
以时间递增的顺序输出答案。(如果找不到合法答案,这组数据什么都不要输出)

Sample Input

99000
0

Sample Output

00:01:30
11:58:30
00:00:00

HINT

题意

题解:

初中数学题……

代码

#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <queue>
#include <typeinfo>
#include <fstream>
#include <map>
#include <stack>
typedef long long ll;
using namespace std;
//freopen("D.in","r",stdin);
//freopen("D.out","w",stdout);
#define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
#define test freopen("test.txt","r",stdin)
#define maxn 1050005
#define mod 10007
#define eps 1e-9
const int inf=0x3f3f3f3f;
const ll infll = 0x3f3f3f3f3f3f3f3fLL;
inline ll read()
{
    ll x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
//**************************************************************************************
int kiss=360*12000;
int main()
{
    int x;
    while(cin>>x)
    {

        for(int i=0;i<12;i++)
        {
            for(int j=0;j<=59;j++)
            {
                for(int k=0;k<=50;k+=10)
                {
                    int t1=30*12000*i+6000*j+100*k;
                    int t2=12000*6*j+1200*k;
                    int t=(t1-t2);
                    while(t>=kiss)
                        t-=kiss;
                    while(t<0)
                        t+=kiss;
                    if(t>kiss/2)
                        t=kiss-t;
                    if(t==x)
                        printf("%02d:%02d:%02d
",i,j,k);
                }
            }
        }
    }
}
原文地址:https://www.cnblogs.com/qscqesze/p/4621596.html