constchar* rev = "A 3 HIL JM O 2TUVWXY51SE Z 8 "; constchar* res[] = {"not a palindrome", "a regular palindrome", "a mirrored string", "a mirrored palindrome"};
charr(char ch) { if(ch >= 'A' && ch <= 'Z') return rev[ch - 'A']; else return rev[ch - '0' + 25]; } intmain() { char s[30]; while(~scanf("%s", s)) { int len = strlen(s); int p = 1, m = 1; for(int i = 0; i < (len + 1) / 2; ++i) { if(s[i] != s[len - 1 - i]) p = 0; if(r(s[i]) != s[len-1-i]) m = 0; } printf("%s -- is %s.\n\n", s, res[m * 2 + p]); } return0; }
#include<cstdio> #include<iostream> #include<cstring> #include<algorithm> #include<cmath> usingnamespacestd; constint MAX = 100010;
int t, n; int res[MAX]; voidinit() { for(int i = 1; i < MAX; ++i) { int x = i, y = i; while(x) { y += x % 10; x /= 10; } if(res[y] == 0 || i < res[y]) res[y] = i; } } intmain() { init(); scanf("%d",&t); while(t--) { scanf("%d",&n); printf("%d\n", res[n]); } return0; }
intles(char* s, int p, int q) { int n = strlen(s); for(int i = 0; i < n; ++i) { if(s[(p+i)%n] != s[(q+i)%n]) return s[(p+i)%n] < s[(q+i)%n]; } return0; } intmain() { char s[105]; int n, ans, len; while(~scanf("%d",&n)) { while(n--) { ans = 0; scanf("%s",s); len = strlen(s); for(int i = 0; i < len; ++i) if(les(s, i, ans)) ans = i; for(int i = 0; i < len; ++i) cout << s[(ans+i)%len]; cout << endl; } } return0; }