HDU 5387 Clock

又是一道模拟题(为什么这次周赛题这么简单?)

题解也不写了

#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
inline int read(){
	int x=0,f=1,ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
inline int gcd(int x,int y){
	if(!x) return y;
	return gcd(y%x,x);
}
inline int cal(int x,int y){
	int res=x-y;
	if(res<0) res=-res;
	if(res>21600) res=43200-res;
	return res;
}
inline void print(int x){
	int res=gcd(x,120);
	if(res==120) printf("%d ",x/120);
	else printf("%d/%d ",x/res,120/res);
}
int main(){
	int T=read();
	while(T--){
		int hh=read(),mm=read(),ss=read();
		if(hh>=12) hh-=12;
		hh=hh*3600+mm*60+ss;
		mm=mm*720+ss*12;
		ss=ss*720;
		print(cal(hh,mm));
		print(cal(hh,ss));
		print(cal(mm,ss));
		puts("");
	}
	return 0;
}

  

posted @ 2018-11-05 08:55  古城独钓  阅读(113)  评论(0编辑  收藏  举报