UVA 10339
题意是:有两个时钟,分别慢了k秒和m秒,12:00开始一起走,就下次重合的时间是多少,首先先求出它们的差值,在让43200除以它就得到多岁天后重合,然后就好算了。
看AC代码:
1 #include <bits/stdc++.h> 2 using namespace std; 3 #define ll long long 4 const int R = 12*60*60; 5 const int D = 24*60*60; 6 7 int main(){ 8 int k,m; 9 while(cin>>k>>m){ 10 int cnt = abs(k-m); 11 if(cnt == 0){ 12 printf("%d %d 12:00 ",k,m); 13 continue; 14 } 15 double d = R*1.0/cnt; 16 int t = (int)(d*(D-k)/60+0.5)%D; 17 int h = t/60; 18 h%=12; 19 if(h==0) h = 12; 20 int mm = t%60; 21 printf("%d %d %02d:%02d ",k,m,h,mm); 22 } 23 return 0; 24 }