Keyword: ad hoc
Algorithm:
It can be solved using time subtraction. Only remember that you should print 12:30 instead of 0:30.
Code:
#include<cstdio>
int main()
{
int t, h, m, ans;
scanf( "%d", &t );
while( t-- )
{
scanf( "%d:%d", &h, &m );
ans = 720 - 60 * h - m;
if( ans < 60 )
ans += 720;
printf( "%02d:%02d\n", ans / 60, ans % 60 );
}
return 0;
}
沒有留言:
張貼留言