#include <iostream> #include <math.h> using namespace std; string s; double n,m; int i=0,n1,z=0; char x,y; int main() { cin>>n; if(n>0) { m=ceil(n/2)-1; n1=n; for(z=0; z<ceil(n/2); z++) cin>>s[z]; if(n1%2!=0) m--; n--; while(x==y&&i<ceil(n/2)) { x=s[m]; cin>>y; m--; i++; } } else { cin>>s; n=s.length(); m=n; while(x==y&&i<ceil(n/2)) { x=s[i]; y=s[m-1]; m--; i++; } } if(i==ceil(n/2)) cout<<"TAK"; else cout<<"NIE"; return(0); }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | #include <iostream> #include <math.h> using namespace std; string s; double n,m; int i=0,n1,z=0; char x,y; int main() { cin>>n; if(n>0) { m=ceil(n/2)-1; n1=n; for(z=0; z<ceil(n/2); z++) cin>>s[z]; if(n1%2!=0) m--; n--; while(x==y&&i<ceil(n/2)) { x=s[m]; cin>>y; m--; i++; } } else { cin>>s; n=s.length(); m=n; while(x==y&&i<ceil(n/2)) { x=s[i]; y=s[m-1]; m--; i++; } } if(i==ceil(n/2)) cout<<"TAK"; else cout<<"NIE"; return(0); } |