题 意:给你北京时间,让你求其他时区的时间。
输入范围:
1<=t<=1e6
0<=x,x.y<=14
输入样例:
3
11 11 UTC+8
11 12 UTC+9
11 23 UTC+0
输出样例:
11:11
12:12
03:23
收 获:至少知道了时区的转换
思 路:开始的时候被输入数据刚给吓到了,不是只有东12和西12吗?其实不用管。还是一样的算法。之前写的太复杂了,看了杜教的代码。简洁。
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define N 1000005
using namespace std;
typedef long long ll;
const int maxn = 1e3+5;
int h,m;
char s[100];
double d;
int main() {
int t;
scanf("%d",&t);
while(t--){
scanf("%d %d %s",&h,&m,s);
h = h*60+m;
sscanf(s+4,"%lf",&d);
int flag = s[3] == '-'?-1:1; //有点学的僵化了
int c = int(d*10+0.1);
m = flag*c*6 - 8*60;
h += m;
h%=24*60;
if(h<0)h+=24*60;
printf("%02d:%02d\n",h/60,h%60);
}
return 0;
}