【题目】
Time ZoneTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2882 Accepted Submission(s): 914 Problem Description Chiaki often participates in international competitive programming contests. The time zone becomes a big problem.
Input There are multiple test cases. The first line of input contains an integer T (1≤T≤106 ), indicating the number of test cases. For each test case:
Output For each test, output the time in the format of hh:mm (24-hour clock).
Sample Input 3 11 11 UTC+8 11 12 UTC+9 11 23 UTC+0
Sample Output 11:11 12:12 03:23
|
【题解】
题意:给定UTC+8的北京时间,输出给定时区的时间。
思路:转化为分钟即可。wa到心态爆炸,一定要注意精度丢失的问题!!!
【代码】
#include<stdio.h>
main()
{
int t,a,b;
double d;
scanf("%d",&t);
while(t--)
{
scanf("%d%d UTC%lf",&a,&b,&d);
int sum=a*60+b-8*60;
if(d>0)
sum+=(int)(d*10+0.1)*6;
else
sum+=(int)(d*10-0.1)*6;
sum%=24*60;
if(sum<0)
sum+=24*60;
printf("%02d:%02d\n",sum/60,sum%60);
}
}