Tick and Tick
Time limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total submission (s): 16707 Accepted Submission (s): 4083
Problem DescriptionThe Three hands of the clock is rotating every second and meeting all other many times everyday. Finally, they get bored of this and all of the them would like to stay away from the other. A Hand is happy if it's at least D degrees from any of the rest. You is to calculate what much time in a day and all the hands is happy.
Inputthe input contains many test cases. Each of them have a single line with a real number D between 0 and inclusively. The input is terminated with a D of-1.
Outputfor each D, print in a, and the percentage of time in a, and all of the hands is happy, accurate up to 3 Decimal places.
Sample input012090-1
Sample Output100.0000.0006.251
Authorpan, Minghao
SourceZJCPC2004
Calculates the time, period, and cycle of each two pointers required to meet the required angle.
#include <iostream>#include<stdio.h>using namespacestd;DoubleMaxDoubleADoubleBDoublec) { Doubletemp= (a>b)?a:b; return(temp>c)?temp:c;}DoubleMinDoubleADoubleBDoublec) { Doubletemp= (a<b)?a:b; return(temp<c)?temp:c;}intMain () {DoubleWh=360.0/ A/3600; Doublewm=360.0/ -/ -; DoubleWs=360.0/ -; Doublewhm=wm-WH; Doublewhs=ws-WH; Doublewms=ws-WM; //cout<<whm<<endl<<whs<<endl<<wms<<endl; DoubleN; while(~SCANF ("%LF", &n) &&n!=-1) { Doublestahm=n/WHM; Doublestahs=n/WHS; Doublestams=n/WMS; DoubleEndhm= ( the-N)/WHM; DoubleEndhs= ( the-N)/WHS; DoubleEndms= ( the-N)/WMS; DoubleShm,shs,sms,ehm,ehs,ems; Const Doublet_hm=43200.0/ One, t_hs=43200.0/719, t_ms=3600.0/ -;//Ïà¶ôöüæú Doublesum=0; //cout<< "Do" <<endl; for(SHM=STAHM,EHM=ENDHM; ehm<43200.000001; shm+=t_hm,ehm+=t_hm) { //cout<<shm<<endl; for(SHS=STAHS,EHS=ENDHS; ehs<43200.000001; shs+=t_hs,ehs+=t_hs) { if(EHM<SHS) Break; if(SHM>EHS)Continue; for(SMS=STAMS,EMS=ENDMS; ems<43200.000001; sms+=t_ms,ems+=T_ms) { if(ehm<sms| | EHS<SMS) Break; if(shm>ems| | Shs>ems)Continue; //cout<< "doing" <<endl; DoubleXsta=Max (shm,shs,sms); DoubleXend=min (ehm,ehs,ems); if(xsta<xend) Sum+ = (xend-Xsta); }}} printf ("%.3lf\n", sum/432); } return 0;}View Code
HDU 1006 Tick and tick tricks of violence