{"id":183,"date":"2024-04-26T16:48:28","date_gmt":"2024-04-26T08:48:28","guid":{"rendered":"https:\/\/seanxd.com\/?p=183"},"modified":"2024-04-26T16:48:30","modified_gmt":"2024-04-26T08:48:30","slug":"zerojudge-b294","status":"publish","type":"post","link":"https:\/\/seanxd.com\/en\/zerojudge-b294\/","title":{"rendered":"ZeroJudge B294: Economic Crisis"},"content":{"rendered":"<p class=\"translation-block\">On January 1st, 2505, there was a worldwide economic crisis. From that day on, prices soared. The price for one bun was one dollar on the first day, two dollars on the second day, three dollars on the third day, and so on.<\/p>\n\n\n\n<p class=\"\">Given the number of buns Wen-Wen bought each day starting from the first day, how much money did he spend in total?<\/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 an integer N, representing the number of consecutive days Wen-Wen bought buns starting from the first day.<br>The second line will contain N integers, representing the number of buns Wen-Wen bought each day from the first day to the N-th day.<\/td><td>Output the total amount of money Wen-Wen spent on buns.<\/td><\/tr><tr><td>5<br>1  2  3  4  5<\/td><td>55<\/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\">Use a for loop to iterate from 1 to N, multiplying the received data by i and adding it to a sum variable. Finally, output the value of the sum variable.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Sample Code\uff0d<a href=\"https:\/\/zerojudge.tw\/ShowProblem?problemid=b294\" target=\"_blank\" rel=\"noreferrer noopener\">ZeroJudge B294: Economic Crisis<\/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;\n#include &lt;stdio.h&gt;\nusing namespace std;\n\nint main() {\n  int N;\n  scanf(&quot;%d&quot;, &N); \n  int ans = 0;\n  for (int i = 1; i&lt;=N; i++)\n    {\n      int tmp;\n      scanf(&quot;%d&quot;, &tmp);\n      ans += tmp * i;\n    }\n  printf(&quot;%d\\n&quot;, ans);\n}\n\n\/\/Z.O.J. B294\n\/\/Dr. SeanXD<\/code><\/pre><\/div>","protected":false},"excerpt":{"rendered":"<p>\u897f\u5143 2505 \u5e74 1 \u6708 1 \u65e5\uff0c\u767c\u751f\u4e86\u4e16\u754c\u7d93\u6fdf\u5927\u6050\u8352\u3002\u5f9e\u90a3\u5929\u8d77\uff0c\u7269\u50f9\u98db\u6f32\u3002\u7b2c\u4e00\u5929\u4e00\u500b\u9945\u982d\u53ea\u8981\u4e00\u5143\uff0c\u7b2c\u4e8c\u5929\u5c31 [&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":[13,9],"class_list":["post-183","post","type-post","status-publish","format-standard","hentry","category-6","tag-13","tag-9"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/183","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=183"}],"version-history":[{"count":2,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/183\/revisions"}],"predecessor-version":[{"id":185,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/183\/revisions\/185"}],"wp:attachment":[{"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/media?parent=183"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/categories?post=183"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/tags?post=183"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}