首页 > ACM题库 > HDU-杭电 > HDU 4103-Clock[解题报告]HOJ
2015
04-16

HDU 4103-Clock[解题报告]HOJ

Clock

问题描述 :

Books

There is only one Big Clock in the Alibaba’s headquarters on Mars. Since it is on Mars, the Clock is different as it was on Earth.
There are A hours per day and B minutes per hour. The Clock has two hands, the hour hand and the minute hand. The hour hand travels 360 degrees per day and the minute hand travels 360 degrees per hour. Both hands travel consecutively.
But for some reason, the Clock is not very steady. One day the Clock drops off the wall, but fortunately, it is still working. So they plans to put it back onto the wall. But they soon found a problem: it’s the only clock they have, so they don’t know the current time now. Clock only shows the relative position between the two hands, but doesn’t show how to place it (as there are no marks on it), so it can be rotated and represent several different times.
They want your help to determine how many different times the clock may represent.

输入:

The input consists several testcases.
Every test case only contains one line with two integers A, B (1 <= A,B <= 109) and a real number θ (0 < θ < 2 π), means that there are A hours per day and B minutes per hour, and the minute hand is θ rad ahead of the hour hand)
Input ends with one line containing “0 0 0”.

输出:

The input consists several testcases.
Every test case only contains one line with two integers A, B (1 <= A,B <= 109) and a real number θ (0 < θ < 2 π), means that there are A hours per day and B minutes per hour, and the minute hand is θ rad ahead of the hour hand)
Input ends with one line containing “0 0 0”.

样例输入:

1 1 1.57
0 0 0

样例输出:

0

#include<stdio.h>
#include<iostream>
#include<string>
#include<stdlib.h>
#include<math.h>
#include<algorithm>
#include<queue>
using namespace std;
int a,b;
double c,d,t,pi;
bool flag;

int main()
{
    pi = 3.1416926536;
    while(scanf("%d%d%lf",&a,&b,&c)!=EOF && (a!=0 || b !=0 || fabs(c)>0.0000001))
    {
        printf("%d\n",a - 1);
    }
    return 0;
}

  1. 一开始就规定不相邻节点颜色相同,可能得不到最优解。我想个类似的算法,也不确定是否总能得到最优解:先着一个点,随机挑一个相邻点,着第二色,继续随机选一个点,但必须至少有一个边和已着点相邻,着上不同色,当然尽量不增加新色,直到完成。我还找不到反例验证他的错误。。希望LZ也帮想想, 有想法欢迎来邮件。谢谢

  2. Thanks for taking the time to examine this, I really feel strongly about it and love studying a lot more on this topic. If possible, as you acquire experience