#include #include #include #include using namespace std; bool intervalOra(int a) {return a>=0 && a<=23;} bool intervalMinute(int a) {return a>=0 && a<=59;} bool gramaticalOK(char *str) { if(strlen(str)!=5) return false; if(str[2]!=':') return false; for(int i=0;i<=4;i++) if(i!=2) if(!(str[i]>='0' && str[i]<='9')) return false; char p[5]; strcpy(p,str); p[2]=NULL; if(!intervalOra(atoi(p))) return false; strcpy(p,str+3); if(!intervalMinute(atoi(p))) return false; return true; } bool exactHour(char *str) { return ('0' == str[3] and '0' == str[4]); } bool doubleTime(char *str) { return str[0]==str[3] && str[1]==str[4]; } bool mirrorTime(char *str) { return str[0]==str[4] && str[1]==str[3]; } bool increasingTime(char *str) { return str[1]==str[0]+1 && str[3]==str[1]+1 && str[4]==str[3]+1; } bool _2powerTime(char *str) { char s[6]; strcpy(s,str); strcpy(s+2,s+3); int a=atoi(s); if(a<=1) return false; while(a%2!=1) a/=2; return a==1; } bool peculiar(char *str) { return gramaticalOK(str) && (exactHour(str) || doubleTime(str) || mirrorTime(str) || increasingTime(str) || _2powerTime(str)); } int main() { int n; char s[6],c[1]; ifstream f("input"); f >> n ; f.getline(c,1); for(int i=0;i