1. 程式人生 > >#419(div2) A. Karen and Morning

#419(div2) A. Karen and Morning

return main name spa ring 思路 clas 判斷 bit

題意:給出某個時刻,問多少秒後時刻變成回文的了

思路:A題就直接暴力咯,一秒一秒加,判斷,註意:24點為0點

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 
 4 int main(){
 5     string s1;
 6     cin>>s1;
 7     int x1=s1[0]-0;
 8     int x2=s1[1]-0;
 9     int y1=s1[3]-0;
10     int y2=s1[4]-0;
11     for(int i=0;;i++){
12         if
(i!=0) 13 y2++; 14 if(y2>=10){ 15 y2=y2%10;y1++; 16 } 17 if(y1>=6){ 18 y1=y1%6;x2++; 19 } 20 if(x2>=10){ 21 x2=x2%10;x1++; 22 } 23 if(x1==2&&x2==4){ 24 x1=0;x2=0; 25 } 26 if
(x1==y2&&y1==x2){ 27 printf("%d\n",i);return 0; 28 } 29 } 30 return 0; 31 }

#419(div2) A. Karen and Morning