{"id":411,"date":"2013-07-17T15:08:41","date_gmt":"2013-07-17T07:08:41","guid":{"rendered":"http:\/\/blog.dayandcarrot.net\/?p=411"},"modified":"2013-07-17T15:08:41","modified_gmt":"2013-07-17T07:08:41","slug":"1058-ab-in-hogwarts-20","status":"publish","type":"post","link":"https:\/\/dayandcarrot.space\/?p=411","title":{"rendered":"1058. A+B in Hogwarts (20)"},"content":{"rendered":"<p>If you are a fan of Harry Potter, you would know the world of magic has its own currency system &#8212; as Hagrid explained it to Harry, &#8220;Seventeen silver Sickles to a Galleon and twenty-nine Knuts to a Sickle, it&#8217;s easy enough.&#8221; Your job is to write a program to compute A+B where A and B are given in the standard form of &#8220;Galleon.Sickle.Knut&#8221; (Galleon is an integer in [0, 10<sup>7<\/sup>], Sickle is an integer in [0, 17), and Knut is an integer in [0, 29)).<br \/>\n<b>Input Specification:<\/b><br \/>\nEach input file contains one test case which occupies a line with A and B in the standard form, separated by one space.<br \/>\n<b>Output Specification:<\/b><br \/>\nFor each test case you should output the sum of A and B in one line, with the same format as the input.<br \/>\n<b>Sample Input:<\/b><\/p>\n<pre>3.2.1 10.16.27<\/pre>\n<p><b>Sample Output:<\/b><\/p>\n<pre>14.1.28<\/pre>\n<p>===========================<br \/>\n\u5f88\u7b80\u5355\u7684\u95ee\u9898\uff0c\u5c31\u4e0d\u591a\u5199\u4e86~\u4ee3\u7801\u4e5f\u5f88\u7c97\u7cd9\uff0c\u563f\u563f<\/p>\n<pre>\n#include <stdio.h>\nusing namespace std;\nint main()\n{\n\tlong galleon[2] = {0,0};\n\tint sickle[2] = {0,0}, knut[2] = {0,0};\n\tscanf(\"%ld.%d.%d\", &galleon, &sickle, &knut);\n\tscanf(\"%ld.%d.%d\", &galleon[1], &sickle[1], &knut[1]);\n\tlong G = 0;\n\tint  S=0, K=0;\n\tK = knut[0] + knut[1];\n\twhile(K > 28)\n\t{\n\t\tK -= 29;\n\t\tS ++;\n\t}\n\tS += sickle[0];\n\tS += sickle[1];\n\twhile(S > 16)\n\t{\n\t\tS -= 17;\n\t\tG ++;\n\t}\n\tG += galleon[0];\n\tG += galleon[1];\n\tprintf(\"%ld.%d.%d\",G, S, K);\n\treturn 0;\n}\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>If you are a fan of Harry Potter, you would know the world of magic has its own currency system &#8212; as Hagrid explained it to Harry, &#8220;Seventeen silver Sickles to a Galleon and twenty-nine Knuts to a Sickle, it&#8217;s easy enough.&#8221; Your job is to write a program to compute A+B where A and [&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-411","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\/411","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=411"}],"version-history":[{"count":0,"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=\/wp\/v2\/posts\/411\/revisions"}],"wp:attachment":[{"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=411"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=411"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=411"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}