Created
January 16, 2013 18:19
-
-
Save Bekt/4549387 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 99 | |
| Anna | |
| aToyota | |
| sonor | |
| Union | |
| University | |
| man | |
| woman | |
| palindrome | |
| poor | |
| feed | |
| look | |
| zoomy | |
| moon | |
| tight | |
| a | |
| b | |
| c | |
| d | |
| e | |
| f | |
| g | |
| h | |
| i | |
| j | |
| k | |
| l | |
| m | |
| n | |
| o | |
| p | |
| q | |
| r | |
| s | |
| t | |
| u | |
| v | |
| w | |
| x | |
| y | |
| z | |
| A | |
| B | |
| C | |
| D | |
| E | |
| F | |
| G | |
| H | |
| I | |
| J | |
| K | |
| L | |
| M | |
| N | |
| O | |
| P | |
| Q | |
| R | |
| S | |
| T | |
| U | |
| V | |
| W | |
| X | |
| Y | |
| Z | |
| ac | |
| df | |
| gi | |
| jl | |
| mo | |
| ps | |
| tv | |
| wz | |
| AMZ | |
| DOT | |
| abc | |
| def | |
| ghi | |
| jkl | |
| mno | |
| pqrs | |
| tuv | |
| wxyz | |
| ABC | |
| DEF | |
| GHI | |
| JKL | |
| MNO | |
| PQRS | |
| TUV | |
| WXYZ | |
| aDgJmPtWzVsOlIfC | |
| ABCDEFGHIJKGHIDEFABC | |
| abcdefghijklmnopqrst | |
| ABCDEFGHIJKLMNOPQRST | |
| aaaaaaaaaaaaaaaaaaaa | |
| zzzzzzzzzzzzzzzzzzzz | |
| mmmnnnooommmnnnooomm |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.io.File; | |
| import java.util.*; | |
| //2012: http://www.ccsc-ms.org/2012_Problems/pdfs/E-phone.pdf | |
| //Status: AC | |
| public class phone { | |
| static Scanner in; | |
| public static void main(String[] args) throws Exception { | |
| in = new Scanner(new File("phone.in")); | |
| new phone().run(); | |
| } | |
| void run() { | |
| int n = in.nextInt(); in.nextLine(); | |
| String conv; | |
| for (int i = 0; i < n; i++) { | |
| conv = translate(in.nextLine()); | |
| if (isPalin(conv)) | |
| System.out.println("YES"); | |
| else | |
| System.out.println("NO"); | |
| } | |
| } | |
| String translate(String word) { | |
| word = word.toUpperCase(); | |
| StringBuilder ret = new StringBuilder(); | |
| for (int i = 0; i < word.length(); i++) | |
| ret.append(getNum(word.charAt(i))); | |
| return ret.toString(); | |
| } | |
| char getNum(char c) { | |
| if (c == 'A' || c == 'B' || c == 'C') | |
| return '2'; | |
| if (c == 'D' || c == 'E' || c == 'F') | |
| return '3'; | |
| if (c == 'G' || c == 'H' || c == 'I') | |
| return '4'; | |
| if (c == 'J' || c == 'K' || c == 'L') | |
| return '5'; | |
| if (c == 'M' || c == 'N' || c == 'O') | |
| return '6'; | |
| if (c == 'P' || c == 'Q' || c == 'R' || c == 'S') | |
| return '7'; | |
| if (c == 'T' || c == 'U' || c == 'V') | |
| return '8'; | |
| return '9'; | |
| } | |
| boolean isPalin(String text) { | |
| int size = text.length(); | |
| for (int i = 0, j = size - 1; i < size / 2; i++, j--) { | |
| if (text.charAt(i) != text.charAt(j)) | |
| return false; | |
| } | |
| return true; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment