HDU 1006 Tick and tick tricks of violence

Source: Internet
Author: User

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&LT;SHS) Break; if(SHM&GT;EHS)Continue;  for(SMS=STAMS,EMS=ENDMS; ems<43200.000001; sms+=t_ms,ems+=T_ms) {                    if(ehm<sms| | EHS&LT;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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.