{"id":306,"date":"2013-06-04T10:41:32","date_gmt":"2013-06-04T02:41:32","guid":{"rendered":"http:\/\/blog.dayandcarrot.net\/?p=306"},"modified":"2013-06-04T10:41:32","modified_gmt":"2013-06-04T02:41:32","slug":"1027-colors-in-mars-20","status":"publish","type":"post","link":"https:\/\/dayandcarrot.space\/?p=306","title":{"rendered":"1027. Colors in Mars (20)"},"content":{"rendered":"<h1>1027. Colors in Mars (20)<\/h1>\n<div id=\"problemInfo\">\n<div>\n<div>\u65f6\u95f4\u9650\u5236<\/div>\n<div>400 ms<\/div>\n<\/div>\n<div>\n<div>\u5185\u5b58\u9650\u5236<\/div>\n<div>32000 kB<\/div>\n<\/div>\n<div>\n<div>\u4ee3\u7801\u957f\u5ea6\u9650\u5236<\/div>\n<div>16000 B<\/div>\n<\/div>\n<div>\n<div>\u5224\u9898\u7a0b\u5e8f<\/div>\n<div>Standard<\/div>\n<\/div>\n<div>\u4f5c\u8005<\/div>\n<div>CHEN, Yue<\/div>\n<\/div>\n<div id=\"problemContent\">\nPeople in Mars represent the colors in their computers in a similar way as the Earth people. That is, a color is represented by a 6-digit number, where the first 2 digits are for Red, the middle 2 digits for Green, and the last 2 digits for Blue. The only difference is that they use radix 13 (0-9 and A-C) instead of 16. Now given a color in three decimal numbers (each between 0 and 168), you are supposed to output their Mars RGB values.<br \/>\n<b>Input<\/b><br \/>\nEach input file contains one test case which occupies a line containing the three decimal color values.<br \/>\n&nbsp;<br \/>\n<b>Output<\/b><br \/>\nFor each test case you should output the Mars RGB value in the following format: first output &#8220;#&#8221;, then followed by a 6-digit number where all the English characters must be upper-cased. If a single color is only 1-digit long, you must print a &#8220;0&#8221; to the left.<br \/>\n<b>Sample Input<\/b><\/p>\n<pre>15 43 71<\/pre>\n<p><b>Sample Output<\/b><\/p>\n<pre>#123456<\/pre>\n<p>&nbsp;\n<\/p><\/div>\n<p>===============================<br \/>\n\u6ca1\u5565\u6280\u672f\u542b\u91cf\u3002<br \/>\n===============================<\/p>\n<pre>\n#include <iostream>\n#include <string>\nusing namespace std;\nstring GetRGBVal(int val)\n{\n\tchar ret[3];\n\tret[2] = '\u0000';\n\tint count = 1;\n\twhile( count >= 0)\n\t{\n\t\tif(val == 0)\n\t\t\tret[count] = '0';\n\t\tint temp = val % 13;\n\t\tif(temp >9)\n\t\t{\n\t\t\ttemp -= 10;\n\t\t\ttemp += 0x41;\n\t\t}\n\t\telse\n\t\t\ttemp += 0x30;\n\t\tval \/= 13;\n\t\tret[count--] = (char)temp;\n\t}\n\treturn string(ret);\n}\nint main()\n{\n\tint rgb[3];\n\tcin >> rgb[0] >> rgb[1] >> rgb[2];\n\tcout << \"#\";\n\tfor(int i=0; i<3; i++)\n\t{\n\t\tcout << GetRGBVal(rgb[i]);\n\t}\n\treturn 0;\n}\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>1027. Colors in Mars (20) \u65f6\u95f4\u9650\u5236 400 ms \u5185\u5b58\u9650\u5236 32000 kB \u4ee3\u7801\u957f\u5ea6\u9650\u5236 16000 B \u5224\u9898\u7a0b\u5e8f Standard \u4f5c\u8005 CHEN, Yue People in Mars represent the colors in their computers in a similar way as the Earth people. That is, a color is represented by a 6-digit number, where the first 2 digits are for Red, the [&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-306","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\/306","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=306"}],"version-history":[{"count":0,"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=\/wp\/v2\/posts\/306\/revisions"}],"wp:attachment":[{"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=306"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=306"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=306"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}