1、题目链接:http://codeforces.com/contest/387/problem/A
2、就是考察补码知识,先加个24*60然后再运算,这样更简单,不用讨论,就像高精度减法里的“借位”一样。1Y。
#include<cstdio> using namespace std; int main(){ int m1,n1,m2,n2,temp1,temp2; scanf("%d:%d",&m1,&n1); scanf("%d:%d",&m2,&n2); temp1=m1*60+n1+24*60; temp2=m2*60+n2; temp1-=temp2; if(temp1>=24*60) temp1-=24*60; m1=temp1/60; n1=temp1%60; if(m1>=0&&m1<=9) printf("0%d",m1); else printf("%d",m1); printf(":"); if(n1>=0&&n1<=9) printf("0%d",n1); else printf("%d",n1); printf("\n"); return 0; }