POJ 2840
1 #include<iostream> 2 #include<stdio.h> 3 #include<string> 4 5 using namespace std; 6 7 int main() 8 { 9 //freopen("acm.acm","r",stdin); 10 int i; 11 int num; 12 int sum; 13 string s; 14 cin>>num; 15 while(num --) 16 { 17 cin>>s; 18 i = 0; 19 sum = 0; 20 while(1) 21 { 22 sum += s[i] - '0'; 23 if(s[++i] != ':') 24 sum *= 10; 25 else 26 break; 27 } 28 29 if(s[++i] == '0' && s[++i] == '0') 30 { 31 if(sum == 12) 32 cout<<24<<endl; 33 else 34 cout<<(sum + 12) % 24<<endl; 35 } 36 else 37 { 38 cout<<0<<endl; 39 } 40 41 } 42 }