{"id":221,"date":"2024-04-26T21:05:09","date_gmt":"2024-04-26T13:05:09","guid":{"rendered":"https:\/\/seanxd.com\/?p=221"},"modified":"2024-04-26T21:05:12","modified_gmt":"2024-04-26T13:05:12","slug":"zerojudge-g488","status":"publish","type":"post","link":"https:\/\/seanxd.com\/en\/zerojudge-g488\/","title":{"rendered":"ZeroJudge G488: COVID-101"},"content":{"rendered":"<p class=\"translation-block\">At the beginning of the school year, the Computer Science Club was already infected with a virus called COVID-101. Those who contracted this disease would constantly act weak and often mention \"computing.\" COVID-101 spreads in a special way: on the <strong>x-th day, there are n(x) = n(x \u2013 1) + x<sup>2<\/sup> \u2013 x + 1<\/strong> viruses. Please calculate the number of COVID-101 viruses <strong>n(x)<\/strong> after <strong>x<\/strong> days.<\/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>Input an integer, representing the number of days x.<br>x &lt;= 200<\/td><td>Output n(x).<\/td><\/tr><tr><td>2<\/td><td>4<\/td><\/tr><tr><td>10<\/td><td>340<\/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\">You can use a recursive function to return the value, and the termination condition would be when N=1, then return 1.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Sample Code\uff0d<a href=\"https:\/\/zerojudge.tw\/ShowProblem?problemid=g488\" target=\"_blank\" rel=\"noreferrer noopener\">ZeroJudge G488: COVID-101<\/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 calc (int N)\n{\n    if (N == 1) return 1;\n    return calc(N-1) + (N*N) - N + 1;\n}\n\nint main() {\n    cin.sync_with_stdio(0);\n    cin.tie(0);\n    int N;\n    cin &gt;&gt; N;\n    cout &lt;&lt; calc(N) &lt;&lt; &quot;\\n&quot;;\n}\n\n\/\/ZeroJudge G488\n\/\/Dr. SeanXD<\/code><\/pre><\/div>","protected":false},"excerpt":{"rendered":"<p>\u96fb\u7b97\u793e\u5728\u525b\u958b\u5b78\u6642\uff0c\u5c31\u5df2\u7d93\u8513\u5ef6\u4e86\u4e00\u7a2e\u75c5\u6bd2\u7a31\u70baCOVID-101\uff0c\u5f97\u5230\u9019\u7a2e\u75c5\u7684\u4eba\uff0c\u6703\u4e00\u76f4\u760b\u72c2\u88dd\u5f31\uff0c\u4e14\u5e38\u5e38\u628a\u300c\u96fb\u300d\u639b [&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":[8,13,28],"class_list":["post-221","post","type-post","status-publish","format-standard","hentry","category-6","tag-8","tag-13","tag-28"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/221","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=221"}],"version-history":[{"count":1,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/221\/revisions"}],"predecessor-version":[{"id":222,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/posts\/221\/revisions\/222"}],"wp:attachment":[{"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/media?parent=221"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/categories?post=221"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/seanxd.com\/en\/wp-json\/wp\/v2\/tags?post=221"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}