首页 > 其他分享 >uva 579 ClockHands(几何+水题)

uva 579 ClockHands(几何+水题)

时间:2023-07-26 17:32:50浏览次数:41  
标签:579 temp clock ClockHands clocks degrees 00 input uva


                  uva 579 ClockHands


The medieval interest in mechanical contrivances is well illustrated by the development of the mechanical clock, the oldest of which is driven by weights and controlled by a verge, an oscillating arm engaging with a gear wheel. It dates back to 1386.

Clocks driven by springs had appeared by the mid-15th century, making it possible to con- struct more compact mechanisms and preparing the way for the portable clock.

English spring-driven pendulum clocks were first commonly kept on a small wall bracket and later on a shelf. Many bracket clocks contained a drawer to hold the winding key. The earliest bracket clocks, made for a period after 1660, were of architectural design, with pillars at the sides and a pediment on top.

In 17th- and 18th-century France, the table clock became an object of monumental design, the best examples of which are minor works of sculpture.

The longcase clocks (also called grandfather clocks) are tall pendulum clock enclosed in a wooden case that stands upon the floor and is typically from 6 to 7.5 feet (1.8 to 2.3 m) in height. Later, the name ``grandfather clock'' became popular after the popular song "My Grandfather's Clock," written in 1876 by Henry Clay Work.

One of the first atomic clocks was an ammonia-controlled clock. It was built in 1949 at the National Bureau of Standards, Washington, D.C.; in this clock the frequency did not vary by more than one part in 108

Nuclear clocks are built using two clocks. The aggregate of atoms that emit the gamma radiation of precise frequency may be called the emitter clock; the group of atoms that absorb this radiation is the absorber clock. One pair of these nuclear clocks can detect energy changes of one part in 1014 , being about 1,000 times more sensitive than the best atomic clock.

The cesium clock is the most accurate type of clock yet developed. This device makes use of transitions between the spin states of the cesium nucleus and produces a frequency which is so regular that it has been adopted for establishing the time standard.

The history of clocks is fascinating, but unrelated to this problem. In this problem, you are asked to find the angle between the minute hand and the hour hand on a regular analog clock. Assume that the second hand, if there were one, would be pointing straight up at the 12. Give all angles as the smallest positive angles. For example 9:00 is 90 degrees; not -90 or 270 degrees.

Input 

The input is a list of times in the form

H

:

M, each on their own line, with

and

. The input is terminated with the time

0:00. Note that

H may be represented with 1 or 2 digits (for 1-9 or 10-12, respectively);

M is always represented with 2 digits (The input times are what you typically see on a digital clock).

Output 

The output displays the smallest positive angle in degrees between the hands for each time. The answer should between

0 degrees and 180 degrees for all input times. Display each angle on a line by itself in the same order as the input. The output should be rounded to the nearest 1/1000, i.e., three places after the decimal point should be printed.

Sample Input 


12:00 9:00 8:10 0:00


Sample Output 


0.000 90.000 175.000



题目大意:求时针和分针的锐角。


解题思路:只要你知道时钟是怎么运作的,这就是道水题。



#include<stdio.h>
int main() {
	int h, m;
	while (scanf("%d:%d", &h, &m) == 2, h || m) {
		double H = (h % 12) * 30 + 0.5 * m;
		double M = 6 * m;
		double temp = H - M;
		if (temp < 0) {
			temp = -temp;
		 }
		if (temp > 180) {
			temp = 360 - temp;
		}
		printf("%.3f\n", temp);
	}
	return 0;
}








标签:579,temp,clock,ClockHands,clocks,degrees,00,input,uva
From: https://blog.51cto.com/u_16206136/6858299

相关文章

  • uva 12299 RMQ with Shifts(线段树单点更新初步应用)
                                 uva12299RMQwithShiftsInthetraditionalRMQ(RangeMinimumQuery)problem,wehaveastaticarrayA.Thenforeachquery(L,R)(LR),wereporttheminimumvalueamongA[L],A[L+1],...,A[R].N......
  • uva 10061 How many zero's and how many digits ?(在不同进制下分解因子)
                             uva10061Howmanyzero'sandhowmanydigits?Givenadecimalintegernumberyouwillhavetofindouthowmanytrailingzeroswillbethereinitsfactorialinagivennumbersystemandalsoyouwillhaveto......
  • uva 156 Ananagrams(字符串+STL应用)
                         uva156AnanagramsMostcrosswordpuzzlefansareusedtoanagrams--groupsofwordswiththesamelettersindifferentorders--forexampleOPTS,SPOT,STOP,POTSandPOST.Somewordshoweverdonothavethisattribute,......
  • UVA??? 考试 Exam
    本来这篇题解是想在中考前写的,但是直到考前都没调出来,原因是pow()的精度感人。由于\(x\equiv0\pmod{a\cdotb}\),令\(c=\dfrac{x}{ab}\),答案即\(abc\len\)的无序三元组\((a,b,c)\)数量。考虑把无序转成有序,即\(a\leb\lec\),但显然会算少,分\(4\)种情况讨论:\(a=b=c=......
  • UVA10791 最小公倍数的最小和 Minimum Sum LCM 题解
    前言长沙市一中8机房0714模拟测1。传送门blog思路本题思路,首先我们先看$\operatorname{lcm}$,明显要使得这些数的$\operatorname{lcm}=n$那么我们就需要所有的数的质因子必须包含$n$的质因子。若$1\lea,b$,则$a\timesb\gea+b$,所以我们就有了策略。将同一个质因......
  • UVA210 双端队列模拟并行程序
    #include<iostream>#include<algorithm>#include<string>#include<sstream>#include<vector>#include<queue>#include<cstring>usingnamespacestd;constintmaxn=10001;//uva210:题意模拟n个程序的并行执行,有赋值,打印,lock,unlock,......
  • uvalive 3363(区间dp)
    题意:给出一个字符串,问最多能缩减到多短。缩减方式比如:aaaaabbbb->5(a)4(b)nowletsgogogoletsgogogo->now2(lets3(go))题解:区间dp,f[l][r]表示从l到r最多缩减到的长度。#include<stdio.h>#include<string.h>#include<algorithm>usingnamespacestd;constintN=2......
  • uva 1407(树形dp)
    题意:有一个机器人从一个节点进入一棵树,给出n个节点之间的距离,如果机器人的能量为x,也就是最多走x,且机器人不需要回到起点,问机器人最多能走多少个节点。题解:f[i][j][0]:遍历子树i的j个节点且最后不需要回到子树的根节点i最少用多少能量f[i][j][1]:遍历子树i的j个节点且最后回......
  • uva 1474(dp)
    题意:有n个队伍修路,有m个避难所,编号从1开始,给出了每个队伍和避难所的位置,每个队伍和避难所之间的距离是|a[i]-b[j]|,如果为每一个队伍分配避难所,且每个避难所至少被分配一个队伍,问每个队伍和自己的避难所之间最短距离和是多少,给出每个队伍分配的避难所编号。题解:dp的状态很好找,因......
  • uva 12470(矩阵快速幂)
    题意:公式f(n)=f(n-1)+f(n-2)+f(n-3),给出n,f(1)=0,f(2)=1,f(3)=2,要求得出f(n)。题解:普通的矩阵快速幂模板题。#include<stdio.h>#include<string.h>constintMOD=1000000009;structMat{longlongg[3][3];}ori,res;longlongn;Matmultiply(......