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 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
| import java.util.HashMap; import java.util.InputMismatchException; import java.util.Map; import java.util.Scanner;
public class Main {
public static void main(String[] args) { Scanner in = new Scanner(System.in);
final String[] lowDigit = {"tret", "jan", "feb", "mar", "apr", "may", "jun", "jly", "aug", "sep", "oct", "nov", "dec"};
final String[] highDigit = {"", "tam", "hel", "maa", "huh", "tou", "kes", "hei", "elo", "syy", "lok", "mer", "jou"};
Map<String, Integer> map = new HashMap<>(); for (int i = 0; i < lowDigit.length; i++) { map.put(lowDigit[i], i); }
for (int i = 0; i < highDigit.length; i++) { map.put(highDigit[i], 13 + i); }
int n = in.nextInt();
for (int i = 0; i < n; i++) { int numInteger = 0; String numString = null;
try { numInteger = in.nextInt(); } catch (InputMismatchException inputMismatchException) { numString = in.nextLine(); } finally {
if (numString == null) { if (numInteger < 13) { System.out.println(lowDigit[numInteger]); } else { if (numInteger % 13 == 0) { System.out.println(highDigit[numInteger / 13]); } else { System.out.println(highDigit[numInteger / 13] + " " + lowDigit[numInteger % 13]); } } } else { String[] tempString = numString.split(" ");
if (tempString.length == 2) { System.out.println((map.get(tempString[0]) - 13) * 13 + map.get(tempString[1])); } else {
if (map.get(tempString[0]) >= 13) { System.out.println((map.get(tempString[0]) - 13) * 13); } else { System.out.println(map.get(tempString[0])); } } } } } in.close(); } }
|