HDU 5276 YJC tricks time 时针分针角度

题意:给定一个角度x,问是否存在一个时间点,使得时针分针成 x 度角。题中将 x 扩大了12000倍,且只需要求出10秒的整数倍的时间点。按时间从早到晚输出。没有则不输出。







是很水。。。。。可是比赛的时候不知道怎么脑残了把个角度算错了。大于180度的角angle脑残地转换成了angle - 180我也是醉了。。。。。比赛的时候居然还能通过。。。。。

从 0 时 0 分 0 秒到 11 时 59 分 59 秒,每隔10秒枚举时间点,注意每隔10秒分针角度+1,扩大12000倍后就是12000,同理时针角度+1000,注意加到360*12000的时候要变为0,然后计算角度看是否等于题目所给的角度即可。





#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
using namespace std;

const int INF = 360*12000; 扩大12000倍后的周角360度
int x;

void solve()
{
    int ss = 0;
    int h = 0, m = 0;
    for(ss = 0; ss < 43200; ss += 10)
    {
        if(m == INF)
            m = 0;
        int angle = abs(m - h);
        if(angle > INF/2)
            angle = INF - angle; //开始写成了angle -= INF/2好想撞墙
        if(angle == x)
        {
            if(ss/3600 < 10) //前导0
                printf("0");
            printf("%d:", ss/3600);
            if(ss/60%60 < 10)
                printf("0");
            printf("%d:", ss/60%60);
            if(ss%60 < 10)
                printf("0");
            printf("%d\n", ss%60);
        }
        m += 12000;
        h += 1000;
    }
}

int main()
{
    while(scanf("%d", &x) != EOF)
        solve();
    return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值