题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5387
比较水的一道题目,也是自己单翘的第一道题目吧,题意就是找到给定时间时钟三个指针之间的夹角,
需要注意的问题分数的表示方法,辗转相除求最大公因子,同时除去,
此外还应注意夹角为锐角。
#include<stdio.h> #include<cmath> #include<algorithm> using namespace std; int gcd(int a,int b) { int r; if(a<b) {r=a;a=b;b=r;} while(b) { r=a%b; a=b; b=r; } return a; } void per( int &a, int &b){ int tmp = gcd(a,b); a = a / tmp; b = b / tmp; } void show( int a, int b, int c, int d){ ) a = a % ( * b); ) c = c % ( * d); *abs(a*d-b*c); int mot = b*d; son = son %( b*d*); ) son = b*d* - son; per(son,mot); ) printf("%d/%d ",son,mot); else printf("%d ",son); } int main(){ // freopen("test.out","r",stdin); int T; ]; int hh, mm, ss; int total; int total2; int total3; int hour ; int minu ; int sec ; scanf("%d",&T); while(T--){ hour = ; minu = ; sec = ; scanf("%s", in); hh = (]-+(]-'); mm = (]-+(]-'); ss = (]-+(]-'); total = ( ss + mm * + hh * ) % ( * ); total2 = total; total3 = total; per(total,hour); per(total2,minu); per(total3,sec); show(total,hour,total2,minu); show(total,hour,total3,sec); show(total3,sec,total2,minu); printf("\n"); } }