{"id":1748,"date":"2016-01-07T10:49:07","date_gmt":"2016-01-07T02:49:07","guid":{"rendered":"http:\/\/boweihe.me\/?p=1748"},"modified":"2016-01-07T10:49:07","modified_gmt":"2016-01-07T02:49:07","slug":"pat-1100-mars-numbers-20","status":"publish","type":"post","link":"https:\/\/dayandcarrot.space\/?p=1748","title":{"rendered":"PAT 1100. Mars Numbers (20)"},"content":{"rendered":"<p>http:\/\/www.patest.cn\/contests\/pat-a-practise\/1100<br \/>\nPeople on Mars count their numbers with base 13:<\/p>\n<ul>\n<li>Zero on Earth is called &#8220;tret&#8221; on Mars.<\/li>\n<li>The numbers 1 to 12 on Earch is called &#8220;jan, feb, mar, apr, may, jun, jly, aug, sep, oct, nov, dec&#8221; on Mars, respectively.<\/li>\n<li>For the next higher digit, Mars people name the 12 numbers as &#8220;tam, hel, maa, huh, tou, kes, hei, elo, syy, lok, mer, jou&#8221;, respectively.<\/li>\n<\/ul>\n<p>For examples, the number 29 on Earth is called &#8220;hel mar&#8221; on Mars; and &#8220;elo nov&#8221; on Mars corresponds to 115 on Earth. In order to help communication between people from these two planets, you are supposed to write a program for mutual translation between Earth and Mars number systems.<br \/>\n<b>Input Specification:<\/b><br \/>\nEach input file contains one test case. For each case, the first line contains a positive integer N (&lt; 100). Then N lines follow, each contains a number in [0, 169), given either in the form of an Earth number, or that of Mars.<br \/>\n<b>Output Specification:<\/b><br \/>\nFor each number, print in a line the corresponding number in the other language.<br \/>\n<b>Sample Input:<\/b><\/p>\n<pre>4\n29\n5\nelo nov\ntam\n<\/pre>\n<p><b>Sample Output:<\/b><\/p>\n<pre class=\"\">hel mar\nmay\n115\n13<\/pre>\n<p>&nbsp;<br \/>\n\u8fd9\u9898\u6ca1\u4ec0\u4e48\u6280\u672f\u542b\u91cf\uff0c\u76f4\u63a5\u7ed9\u4ee3\u7801\uff08\u6211\u5199\u7684\u80af\u5b9a\u662f\u53f2\u4e0a\u6700\u957f\u54c8\u54c8\u54c8\uff09<\/p>\n<pre class=\"lang:c++ decode:true \">#include &lt;cstdlib&gt;\n#include &lt;cstdio&gt;\n#include &lt;cstring&gt;\nusing namespace std;\nint main()\n{\n\tint N;\n\tscanf(\"%d\", &amp;N);\n\tfor (int i = 0; i &lt; N; i++)\n\t{\n\t\tchar* inStr = new char[8];\n\t\tscanf(\"%s\", inStr);\n\t\tbool isInt = (inStr[0] &gt;= '0' &amp;&amp; inStr[0] &lt;= '9');\n\t\tif (isInt)\n\t\t{\n\t\t\tint value = (int)strtol(inStr, NULL, 10);\n\t\t\tint high = value \/ 13;\n\t\t\tint low = value - 13 * high;\n\t\t\tswitch (high)\n\t\t\t{\n\t\t\tcase 0: break;\n\t\t\tcase 1: printf(\"tam\"); break;\n\t\t\tcase 2: printf(\"hel\"); break;\n\t\t\tcase 3: printf(\"maa\"); break;\n\t\t\tcase 4: printf(\"huh\"); break;\n\t\t\tcase 5: printf(\"tou\"); break;\n\t\t\tcase 6: printf(\"kes\"); break;\n\t\t\tcase 7: printf(\"hei\"); break;\n\t\t\tcase 8: printf(\"elo\"); break;\n\t\t\tcase 9: printf(\"syy\"); break;\n\t\t\tcase 10:printf(\"lok\"); break;\n\t\t\tcase 11:printf(\"mer\"); break;\n\t\t\tcase 12:printf(\"jou\"); break;\n\t\t\tdefault:\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (high &gt; 0 &amp;&amp; low &gt; 0)\n\t\t\t\tprintf(\" \");\n\t\t\tswitch (low)\n\t\t\t{\n\t\t\tcase 0:\n\t\t\t\tif(high &lt; 1)\n\t\t\t\t\tprintf(\"tret\");\n\t\t\t\tbreak;\n\t\t\tcase 1: printf(\"jan\"); break;\n\t\t\tcase 2: printf(\"feb\"); break;\n\t\t\tcase 3: printf(\"mar\"); break;\n\t\t\tcase 4: printf(\"apr\"); break;\n\t\t\tcase 5: printf(\"may\"); break;\n\t\t\tcase 6: printf(\"jun\"); break;\n\t\t\tcase 7: printf(\"jly\"); break;\n\t\t\tcase 8: printf(\"aug\"); break;\n\t\t\tcase 9: printf(\"sep\"); break;\n\t\t\tcase 10:printf(\"oct\"); break;\n\t\t\tcase 11:printf(\"nov\"); break;\n\t\t\tcase 12:printf(\"dec\"); break;\n\t\t\tdefault:\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tbool nextFlag = true;\n\t\t\tint val = 0;\n\t\t\tif (strcmp(inStr, \"tam\") == 0)\n\t\t\t\tval = 1;\n\t\t\telse if (strcmp(inStr, \"hel\") == 0)\n\t\t\t\tval = 2;\n\t\t\telse if (strcmp(inStr, \"maa\") == 0)\n\t\t\t\tval = 3;\n\t\t\telse if (strcmp(inStr, \"huh\") == 0)\n\t\t\t\tval = 4;\n\t\t\telse if (strcmp(inStr, \"tou\") == 0)\n\t\t\t\tval = 5;\n\t\t\telse if (strcmp(inStr, \"kes\") == 0)\n\t\t\t\tval = 6;\n\t\t\telse if (strcmp(inStr, \"hei\") == 0)\n\t\t\t\tval = 7;\n\t\t\telse if (strcmp(inStr, \"elo\") == 0)\n\t\t\t\tval = 8;\n\t\t\telse if (strcmp(inStr, \"syy\") == 0)\n\t\t\t\tval = 9;\n\t\t\telse if (strcmp(inStr, \"lok\") == 0)\n\t\t\t\tval = 10;\n\t\t\telse if (strcmp(inStr, \"mer\") == 0)\n\t\t\t\tval = 11;\n\t\t\telse if (strcmp(inStr, \"jou\") == 0)\n\t\t\t\tval = 12;\n\t\t\tval *= 13;\n\t\t\tint chr = getchar();\n\t\t\tif (chr == ' ')\n\t\t\t\tscanf(\"%s\", inStr);\n\t\t\tif (strcmp(inStr, \"tret\") == 0)\n\t\t\t\tval += 0;\n\t\t\telse if (strcmp(inStr, \"jan\") == 0)\n\t\t\t\tval += 1;\n\t\t\telse if (strcmp(inStr, \"feb\") == 0)\n\t\t\t\tval += 2;\n\t\t\telse if (strcmp(inStr, \"mar\") == 0)\n\t\t\t\tval += 3;\n\t\t\telse if (strcmp(inStr, \"apr\") == 0)\n\t\t\t\tval += 4;\n\t\t\telse if (strcmp(inStr, \"may\") == 0)\n\t\t\t\tval += 5;\n\t\t\telse if (strcmp(inStr, \"jun\") == 0)\n\t\t\t\tval += 6;\n\t\t\telse if (strcmp(inStr, \"jly\") == 0)\n\t\t\t\tval += 7;\n\t\t\telse if (strcmp(inStr, \"aug\") == 0)\n\t\t\t\tval += 8;\n\t\t\telse if (strcmp(inStr, \"sep\") == 0)\n\t\t\t\tval += 9;\n\t\t\telse if (strcmp(inStr, \"oct\") == 0)\n\t\t\t\tval += 10;\n\t\t\telse if (strcmp(inStr, \"nov\") == 0)\n\t\t\t\tval += 11;\n\t\t\telse if (strcmp(inStr, \"dec\") == 0)\n\t\t\t\tval += 12;\n\t\t\tprintf(\"%d\", val);\n\t\t}\n\t\tif (i &lt; N - 1)\n\t\t\tprintf(\"\\n\");\n\t}\n\treturn 0;\n}<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>http:\/\/www.patest.cn\/contests\/pat-a-practise\/1100 People on Mars count their numbers with base 13: Zero on Earth is called &#8220;tret&#8221; on Mars. The numbers 1 to 12 on Earch is called &#8220;jan, feb, mar, apr, may, jun, jly, aug, sep, oct, nov, dec&#8221; on Mars, respectively. For the next higher digit, Mars people name the 12 numbers as &#8220;tam, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[84],"class_list":["post-1748","post","type-post","status-publish","format-standard","hentry","category-study","tag-pat"],"_links":{"self":[{"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=\/wp\/v2\/posts\/1748","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1748"}],"version-history":[{"count":0,"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=\/wp\/v2\/posts\/1748\/revisions"}],"wp:attachment":[{"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1748"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1748"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1748"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}