{"id":82,"date":"2024-04-26T00:26:27","date_gmt":"2024-04-25T16:26:27","guid":{"rendered":"https:\/\/seanxd.com\/?p=82"},"modified":"2024-06-18T16:16:19","modified_gmt":"2024-06-18T08:16:19","slug":"zerojudge-a248","status":"publish","type":"post","link":"https:\/\/seanxd.com\/en\/zerojudge-a248\/","title":{"rendered":"ZeroJudge A248: Training ~ Array"},"content":{"rendered":"<p>Everyone knows that a simple calculator can only compute up to about thirty decimal places.<\/p>\n\n\n\n<p>But the curious Sangye wants to know more precise decimal values.<\/p>\n\n\n\n<p>Please help poor Sangye by creating a program that can perform precise decimal calculations.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Sample Inputs\/Outputs<\/h2>\n\n\n\n<figure class=\"wp-block-table nfd-wb-animate nfd-wb-fade-in-bottom-short\"><table class=\"has-fixed-layout\"><thead><tr><th>Sample Input(s)<\/th><th>Sample Output(s)<\/th><\/tr><\/thead><tbody><tr><td>EOF input: Each input consists of three positive integers a, b, and N.<br>1&lt;= a , b &lt;= 2147483647<br>1 &lt;= N &lt;= 10000<br>(The input will not exceed 1000 lines)<\/td><td>Please output the result of the decimal operation a\/b.<br>Precise to N decimal places.<br>Please round down after the Nth decimal place.<\/td><\/tr><tr><td>18467  41  10<br>26500  6334  10<br>15724  19169  10<br>10  5  3<\/td><td>450.4146341463<br>4.1837701294<br>0.8202827481<br>2.000<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Thought Process<\/h2>\n\n\n\n<p>In this problem, if using cin, optimization is needed to avoid timeouts. Since printf cannot be used to specify the number of decimal places, after outputting the integer part of the answer, run a loop N times to calculate the value after the decimal point for a\/b. Take the remainder of a\/b, then multiply a by 10 while outputting a\/b.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Sample Code\uff0d<a href=\"https:\/\/zerojudge.tw\/ShowProblem?problemid=a248\" target=\"_blank\" rel=\"noreferrer noopener\">ZeroJudge A248: Training ~ Array<\/a><\/h3>\n\n\n\n<div class=\"hcb_wrap nfd-wb-animate nfd-wb-reveal-right\"><pre class=\"prism line-numbers lang-cpp\" data-lang=\"C++\"><code>#include &lt;iostream&gt;\nusing namespace std;\n\nint main() {\n    cin.sync_with_stdio(0);\n    cin.tie(nullptr);\n    int a, b, N;\n    while (cin &gt;&gt; a &gt;&gt; b &gt;&gt; N)\n    {\n        cout &lt;&lt; a\/b &lt;&lt; &quot;.&quot;;\n        for (int i = 0; i&lt;N; i++)\n        {\n            a %= b;\n            a *= 10;\n            cout &lt;&lt; a\/b;\n        }\n        cout &lt;&lt; &quot;\\n&quot;;\n    }\n}\n\n\/\/ZeroJudge A248\n\/\/Dr. SeanXD<\/code><\/pre><\/div>","protected":false},"excerpt":{"rendered":"<p>\u5927\u5bb6\u90fd\u77e5\u9053\uff0c\u5c0f\u7b97\u76e4\u7684\u5c0f\u6578\u904b\u7b97\u53ea\u80fd\u7b97\u51fa\u5c0f\u6578\u9ede\u5f8c\u4e09\u5341\u5e7e\u4f4d \u4f46\u597d\u5947\u7684\u6851\u8449\u60f3\u77e5\u9053\u66f4\u7cbe\u6e96\u7684\u5c0f\u6578\u503c \u8acb\u4f60\u5e6b\u53ef\u6190\u7684\u6851\u8449\u505a\u51fa\u53ef [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"nf_dc_page":"","footnotes":""},"categories":[6],"tags":[7,16,9],"class_list":["post-82","post","type-post","status-publish","format-standard","hentry","category-6","tag-7","tag-tle","tag-9"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/82","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/comments?post=82"}],"version-history":[{"count":4,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/82\/revisions"}],"predecessor-version":[{"id":948,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/82\/revisions\/948"}],"wp:attachment":[{"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/media?parent=82"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/categories?post=82"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/tags?post=82"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}