Uva-401-palindromes

Source: Internet
Author: User

Title Link: palindromes


UVA-401

Palindromes
Time Limit:3000MS Memory Limit: Unknown 64bit IO Format:%lld &%llu

Submit Status

Description

A regular palindrome is a string of numbers or letters so is the same forward as backward. For example, the string"abcdedcba" was a palindrome because it was the same when the string was read from L EFT to right as when the string was read from right to left.


A mirrored string is a string for which when each of the elements of the string was changed to its reverse (if it had a rev Erse) and the string is read backwards the result is the same as the original string. For example, the string"3AIAE" was a mirrored string because "a" and "I" are their own Reverses, and"3" and "E" are each others ' reverses.


A mirrored palindrome is a string that meets the criteria of a regular palindrome and the criteria of a mirrored string. The string"Atoyota" is a mirrored palindrome because if the string was read backwards, the string is the Same as the original and because if each of the characters are replaced by their reverse and the result is read backwards, th E result is the same as the original string.

Of course, "A", "T" , "O" , and "Y" Is all their own reverses.

A List of all valid characters and their reverses are as follows.

Character Reverse Character Reverse Character Reverse
A A M M Y Y
B N Z 5
C O O 1 1
D P 2 S
E 3 Q 3 E
F R 4
G S 2 5 Z
H H T T 6
I I U U 7
J L V V 8 8
K W W 9
L J X X


Note that O (zero) and 0 (the letter) is considered the same character and therefore only the "0" is a valid character.

Input

Input consists of strings (one per line) each of the which would consist of one to twenty valid characters. There'll be is no invalid characters in any of the strings. Your program should read to the end of file.

Output

For each input string, you should print the string starting in column 1 immediately followed by exactly one of the FOLLOWI ng strings.

STRING CRITERIA
" --is not a palindrome." If the string is not a palindrome and is not a mirrored string
" --is a regular palindrome." If the string is a palindrome and was not a mirrored string
" --is a mirrored string." If the string is not a palindrome and is a mirrored string
" --is a mirrored palindrome." If the string is a palindrome and is a mirrored string

Note The output line was to include the -' s and spacing exactly as shown in the table above and demonstrated in the Sample Output below.

In addition, after the output line, you must print a empty line.

Sample Input

Notapalindrome Isapalinilapasi 2a3meas Atoyota

Sample Output

Notapalindrome Isapalinilapasi 2a3meas Atoyota --is a mirrored palindrome.

Hint

Use the C + + 's class of string would be convenient, but not a must



Do a string trick.

Test instructions: Judging is not a palindrome string and symmetric string

Thinking: Write two for the function of judgment OK ~ But that is the valid characters all to list, a little trouble.


AC code (PE up to two times.) ):

/*************************************************************************> File name:d.cpp> Author:zzuspy > Mail: [email protected] > Created time:2014 December 01 Monday 16:42 35 seconds **************************************** /#include <cstdio> #include <cstring> #include <iostream> #include <algorithm> #include <cstdlib> #include <cmath> #include <stack> #include <queue>using namespace Std;int a[100];void init () {a[' a '] = ' a '; a[' E '] = ' 3 '; a[' h '] = ' h '; a[' i '] = ' I '; a[' J '] = ' l '; a[' l '] = ' J '; a[' M '] = ' M '; a[' o '] = ' o '; a[' S '] = ' 2 '; a[' t '] = ' t '; a[' u '] = ' u '; a[' V '] = ' V '; a[' w '] = ' w '; a[' x '] = ' x '; a[' y '] = ' y '; a[' Z '] = ' 5 ' ; a[' 1 '] = ' 1 '; a[' 2 '] = ' S '; a[' 3 '] = ' E '; a[' 5 '] = ' Z '; a[' 8 '] = ' 8 ';} int Judge1 (char b[], int n) {for (int i=0; i<=n/2; i++) {if (b[i]!=b[n-i-1]) return 0;} return 1;} int Judge2 (char b[], int n) {for (int i=0; i<n; i++) {if (b[i]==0) return 0;} for (int i=0; i<=n/2; i++) {if (A[b[i]! = b[n-i-1]) return 0;} Return 1;} int main () {init (); Char Str[25];while (scanf ("%s", str)!=eof) {int len = strlen (str); int a = Judge1 (str, len), B = Judge2 (str , Len), if (a==1&&b==1) printf ("%s--is a mirrored palindrome.\n\n", str); else if (a==0&&b==1) printf ("%s- -is a mirrored string.\n\n ", str); else if (a==1&&b==0) printf ('%s--is a regular palindrome.\n\n ', str); else if (a= =0&&b==0) printf ("%s--is not a palindrome.\n\n", str);} return 0;}



Uva-401-palindromes

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.