{"id":389,"date":"2024-04-29T15:48:17","date_gmt":"2024-04-29T07:48:17","guid":{"rendered":"https:\/\/seanxd.com\/?p=389"},"modified":"2024-04-29T15:48:19","modified_gmt":"2024-04-29T07:48:19","slug":"zerojudge-g496","status":"publish","type":"post","link":"https:\/\/seanxd.com\/en\/zerojudge-g496\/","title":{"rendered":"ZeroJudge G496: Comet Train"},"content":{"rendered":"<p class=\"\">Comet Sister recently built a train and named it the \"Comet Train.\" The most notable feature of this Comet Train is that it continuously accelerates at a fixed rate per second.<\/p>\n\n\n\n<p class=\"\">For example, if the Comet Train wants to accelerate from rest to 100 km\/s with an acceleration of 25 km\/s, it will take 4 seconds to reach its goal.<\/p>\n\n\n\n<p class=\"\">Given the Comet Train's acceleration per second and the desired speed the train is expected to reach, please write a program to calculate how many seconds it will take for the train to reach the specified speed.<\/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>The input consists of two integers, A (where 1 \u2264 A \u2264 10^8) and S (where 1 \u2264 S \u2264 10^9). Here, A represents the acceleration per second of the train, and S represents the desired speed of the train. The two numbers are separated by a single space.<\/td><td>Output an integer representing the minimum number of seconds it takes to reach the desired target speed.<\/td><\/tr><tr><td>25  100<\/td><td>4<\/td><\/tr><tr><td>3  200<\/td><td>67<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Thought Process<\/h2>\n\n\n\n<p class=\"\">The answer is S\/A. You can take the integer inputs and perform integer division, which automatically rounds down.<\/p>\n\n\n\n<p class=\"\">If S%A is not equal to 0, you need to add 1 to the answer because it should be rounded up.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Sample Code\uff0d<a href=\"https:\/\/zerojudge.tw\/ShowProblem?problemid=g496\" target=\"_blank\" rel=\"noreferrer noopener\">ZeroJudge G496: Comet Train<\/a><\/h3>\n\n\n\n<div class=\"hcb_wrap nfd-wb-animate nfd-wb-reveal-right nfd-delay-50\"><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(0);\n    int a, b;\n    cin &gt;&gt; a &gt;&gt; b;\n    int ans = b\/a;\n    if (b % a != 0) ans++;\n    cout &lt;&lt; ans &lt;&lt; &quot;\\n&quot;;\n}\n\n\/\/Z.O.J. G496\n\/\/Dr. SeanXD<\/code><\/pre><\/div>","protected":false},"excerpt":{"rendered":"<p>\u5f57\u661f\u59ca\u59ca\u6700\u8fd1\u88fd\u9020\u4e86\u4e00\u53f0\u5217\u8eca\uff0c\u4e26\u4ee5\u5176\u540d\u547d\u540d\u70ba\u300c\u5f57\u661f\u5217\u8eca\u300d\uff0c\u9019\u53f0\u5f57\u661f\u5217\u8eca\u6700\u5927\u7684\u7279\u9ede\u5c31\u662f\u6703\u4ee5\u6bcf\u79d2\u56fa\u5b9a\u7684\u52a0\u901f\u5ea6\u4e0d\u65b7\u63d0\u5347 [&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":[25],"tags":[8,13,7],"class_list":["post-389","post","type-post","status-publish","format-standard","hentry","category-ioi-apcs","tag-8","tag-13","tag-7"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/389","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=389"}],"version-history":[{"count":2,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/389\/revisions"}],"predecessor-version":[{"id":391,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/389\/revisions\/391"}],"wp:attachment":[{"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/media?parent=389"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/categories?post=389"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/tags?post=389"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}