G-Nana in Wonderland Series--Dream Awake

Source: Internet
Author: User

G-Nana in Wonderland Series--Dream AwakeTime Limit:2000/1000ms (java/others) Memory Limit: 128000/64000kb (java/others) special Judge Submit Statusproblem Description

Nana left the kingdom, to the distance, in the wilderness, Nana saw a big clock, the hour and minute hand on the hands are slowly turning, the wings of the Angel and then appeared, the Angel said: "Outside the sky is already light, nana you do not oversleep yo ~", Nana asked: "How can I wake up?" The angel said, "As long as this clock coincides with the hour hand and the minute hand, you can enter the time tunnel and leave this place." ”

Can you tell Nana how long the hour and minute hand will coincide?

Input

Multiple sets of data, the first line is a positive integer t (t<=100,000), which represents the number of groups of data

For each set of data, for a moment, the format is HH:MM:SS, respectively, the time, minute, and second (using the 24-hour timekeeping method, ranging from 00:00:00~23:59:59)

Output for each set of data, outputs a floating-point number that represents the seconds between the next hour and minute hand, and the error is considered correct within 1e-4. Sample Input
223:59:5900:00:00
Sample Output
1.0000003927.272727
Hint use special Judge test instructions: The primary school competition problem, given you time to judge the clock and the next time the coincidence of minutes; the problem: because the clock every turn 12 hours, the starting point does not count, until a turn, coincident 11 times, because the hour and minute hand walk speed is the same, all, They coincide with the same interval, to find out the time of this interval, you can know when the next coincident time, the time is converted to seconds, and then calculate the coincident interval Num, each time the coincidence is num,num*2,num*3,.. Num*k. The input time is also calculated as the second sum, and then calculate the number of times the next coincident time K=sum/num, all the next coincident time is num=num* (i+1), time subtraction can be,
1#include <iostream>2#include <stdio.h>3#include <stdlib.h>4#include <string.h>5 using namespacestd;6 intMain ()7 {8     Doublenum=1.0* A*3600/ One, S;9     DoubleNUM;Ten     intn,i,t; One     inta,b,c,sum; Ascanf"%d",&T); -      while(t--) -     { thescanf"%d:%d:%d",&a,&b,&c); -sum=a*3600+b* -+c;/*turn the time into seconds*/ -I= (int) (Sum/num);/*calculates the number of times the last coincidence*/ -num=num* (i+1);/*calculate the time of the next coincidence*/ +printf"%.6lf\n", num-sum);/*time of the next coincident output distance*/ -     } +  A     return 0; at}
View Code

G-Nana in Wonderland Series--Dream Awake

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.