{"id":78,"date":"2024-04-26T00:06:34","date_gmt":"2024-04-25T16:06:34","guid":{"rendered":"https:\/\/seanxd.com\/?p=78"},"modified":"2024-06-18T16:15:38","modified_gmt":"2024-06-18T08:15:38","slug":"zerojudge-a244","status":"publish","type":"post","link":"https:\/\/seanxd.com\/en\/zerojudge-a244\/","title":{"rendered":"ZeroJudge A244: Training ~ for + if"},"content":{"rendered":"<p>Content:&nbsp;<\/p>\n\n\n\n<p>Hope the people who are learning about for loops and just starting coding will keep up the good work!&nbsp;<\/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 first line contains a positive integer N, indicating that the following N lines each contain three positive integers a, b, and c (1 \u2264 b, c \u2264 2147483647, 1 \u2264 a \u2264 4).<\/td><td>If a=1, please output b+c.<br>If a=2, please output b-c.<br>If a=3, please output b*c.<br>If a=4, please output b\/c.<br>The results should be output as an integer.<\/td><\/tr><tr><td>4<br>1  2  3<br>2  2  3<br>3  2  3<br>4  2  3<\/td><td>5<br>-1<br>6<br>0<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Thought Process<\/h2>\n\n\n\n<p class=\"translation-block\">In this problem, you need to use \"long long int\" to avoid exceeding the range of int. Use if statements to determine which operation (addition, subtraction, multiplication, or division) to perform for the output.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Sample Code\uff0d<a href=\"https:\/\/zerojudge.tw\/ShowProblem?problemid=a244\" target=\"_blank\" rel=\"noreferrer noopener\">ZeroJudge A244: Training ~ for + if<\/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  int N;\n  cin &gt;&gt; N;\n  for (int i = 0; i&lt;N; i++)\n    {\n      long long int a, b, c;\n      cin &gt;&gt; a &gt;&gt; b &gt;&gt; c;\n      if (a == 1) cout &lt;&lt; b+c &lt;&lt; endl;\n      else if (a == 2) cout &lt;&lt; b-c &lt;&lt; endl;\n      else if (a == 3) cout &lt;&lt; b*c &lt;&lt; endl;\n      else if (a == 4) cout &lt;&lt; b\/c &lt;&lt; endl;\n    }\n}\n\n\/\/ZeroJudge A244\n\/\/Dr. SeanXD<\/code><\/pre><\/div>","protected":false},"excerpt":{"rendered":"<p>\u5167\u5bb9\u5c31\u662f~~~~&nbsp; \u5e0c\u671b\u5b78\u5230for\u8ff4\u5708\u548c\u525b\u958b\u59cbcoding\u7684\u5b78\u5f1f\u597d\u597d\u52a0\u6cb9!!!!&nbsp; \u7bc4\u4f8b\u6e2c [&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":[15,8,13,9],"class_list":["post-78","post","type-post","status-publish","format-standard","hentry","category-6","tag-long-long-int","tag-8","tag-13","tag-9"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/78","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=78"}],"version-history":[{"count":6,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/78\/revisions"}],"predecessor-version":[{"id":1330,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/78\/revisions\/1330"}],"wp:attachment":[{"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/media?parent=78"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/categories?post=78"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/tags?post=78"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}