{"id":33940,"date":"2024-11-01T09:22:13","date_gmt":"2024-11-01T09:22:13","guid":{"rendered":"http:\/\/atmokpo.com\/w\/?p=33940"},"modified":"2024-11-01T10:54:47","modified_gmt":"2024-11-01T10:54:47","slug":"c-coding-test-course-i-will-become-the-president-of-the-residents-association","status":"publish","type":"post","link":"https:\/\/atmokpo.com\/w\/33940\/","title":{"rendered":"C# Coding Test Course, I Will Become the President of the Residents&#8217; Association"},"content":{"rendered":"<p><body><\/p>\n<h2>Problem Description<\/h2>\n<p>\n        The given problem is as follows. You need to write an algorithm to become the head of the residents&#8217; association for the number of floors in an apartment and the number of residents on each floor. The goal is to implement an algorithm that calculates the number of residents on a specific floor.\n    <\/p>\n<p>\n        The apartment has floors from 0 to N (0 \u2264 N \u2264 14), and there are k residents living in apartment k on the n-th floor. For example, there are 3 residents living in apartment 3 on the 3rd floor. The number of residents on each floor is calculated as follows.\n    <\/p>\n<p class=\"example\">\n        &#8211; 1st floor: 1 resident in apartment 1, 2 residents in apartment 2, 3 residents in apartment 3&#8230;<br \/>\n        &#8211; 2nd floor: 1 resident in apartment 1, 3 residents in apartment 2, 6 residents in apartment 3&#8230;<br \/>\n        &#8211; The number of residents in apartment k on the n-th floor is stored as the sum of the number of residents in apartment k-1 on the n-th floor and the number of residents in apartment k on the n-th floor.\n    <\/p>\n<h2>Input Format<\/h2>\n<p>\n        The first line contains the number of test cases T (1 \u2264 T \u2264 100). In the following T lines, each test case provides integers N (0 \u2264 N \u2264 14) and K (1 \u2264 K \u2264 14). Here, N represents the floor number, and K represents the apartment number.\n    <\/p>\n<h2>Output Format<\/h2>\n<p>\n        For each test case, you should output the number of residents in apartment k on the n-th floor.\n    <\/p>\n<h2>Example Input<\/h2>\n<div class=\"code-block\">\n<code><br \/>\n            2<br \/>\n            1 3<br \/>\n            2 3<br \/>\n        <\/code>\n<\/div>\n<h2>Example Output<\/h2>\n<div class=\"code-block\">\n<code><br \/>\n            3<br \/>\n            6<br \/>\n        <\/code>\n<\/div>\n<h2>Problem Solving Process<\/h2>\n<p>\n        To solve this problem, we will use Dynamic Programming (DP) techniques. We can use the following relationship to find the number of residents in apartment k on the n-th floor.\n    <\/p>\n<p class=\"code-block\">\n<code><br \/>\n            residents(n, k) = residents(n-1, 1) + residents(n, k-1)<br \/>\n        <\/code>\n<\/p>\n<p>\n        Here, we initialize residents(0, k) = k and residents(n, 0) = 0. Below are the basic steps for storing the number of residents in a table.\n    <\/p>\n<h3>Step 1: Initialization<\/h3>\n<p>\n        First, declare a 2-dimensional array to store the number of residents and set the initial values.\n    <\/p>\n<div class=\"code-block\">\n<code><br \/>\n            int[,] dp = new int[15, 15]; \/\/ Array for 15 floors and 15 apartments<br \/>\n            for (int i = 0; i &lt;= 14; i++) {<br \/>\n                dp[0, i] = i; \/\/ k residents live in apartment k on the 0th floor.<br \/>\n            }<br \/>\n        <\/code>\n<\/div>\n<h3>Step 2: Fill the DP Table<\/h3>\n<p>\n        We fill in the dp table using a nested loop. We consider all cases for n-th floor and k-th apartment as follows.\n    <\/p>\n<div class=\"code-block\">\n<code><br \/>\n            for (int n = 1; n &lt;= 14; n++) {<br \/>\n                for (int k = 1; k &lt;= 14; k++) {<br \/>\n                    dp[n, k] = dp[n - 1, k] + dp[n, k - 1];<br \/>\n                }<br \/>\n            }<br \/>\n<\/code>\n<\/div>\n<h3>Step 3: Output Results<\/h3>\n<p>\n        Calculate and output the number of residents for all test cases. Below is an example of the final implementation.\n    <\/p>\n<div class=\"code-block\">\n<code><br \/>\n            using System;<br \/>\n            class Program {<br \/>\n                static void Main(string[] args) {<br \/>\n                    int[,] dp = new int[15, 15];<br \/>\n                    for (int i = 0; i &lt;= 14; i++) {<br \/>\n                        dp[0, i] = i;<br \/>\n                    }<br \/>\n                    for (int n = 1; n &lt;= 14; n++) {<br \/>\n                        for (int k = 1; k &lt;= 14; k++) {<br \/>\n                            dp[n, k] = dp[n - 1, k] + dp[n, k - 1];<br \/>\n                        }<br \/>\n                    }<br \/>\n                    int T = int.Parse(Console.ReadLine());<br \/>\n                    for (int t = 0; t &lt; T; t++) {<br \/>\n                        string[] input = Console.ReadLine().Split();<br \/>\n                        int n = int.Parse(input[0]);<br \/>\n                        int k = int.Parse(input[1]);<br \/>\n                        Console.WriteLine(dp[n, k]);<br \/>\n                    }<br \/>\n                }<br \/>\n            }<br \/>\n        <\/code>\n<\/div>\n<h2>Conclusion<\/h2>\n<p>\n        Through this problem, we were able to understand the basic concepts of dynamic programming and enhance our problem-solving skills. This problem is one of the types frequently asked in algorithm tests, and there are various variations. To apply this in actual coding tests, it is important to practice DP techniques repeatedly.\n    <\/p>\n<p><\/body><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Problem Description The given problem is as follows. You need to write an algorithm to become the head of the residents&#8217; association for the number of floors in an apartment and the number of residents on each floor. The goal is to implement an algorithm that calculates the number of residents on a specific floor. &hellip; <a href=\"https:\/\/atmokpo.com\/w\/33940\/\" class=\"more-link\">\ub354 \ubcf4\uae30<span class=\"screen-reader-text\"> &#8220;C# Coding Test Course, I Will Become the President of the Residents&#8217; Association&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[90],"tags":[],"class_list":["post-33940","post","type-post","status-publish","format-standard","hentry","category-c-coding-test-tutorials"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>C# Coding Test Course, I Will Become the President of the Residents&#039; Association - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/atmokpo.com\/w\/33940\/\" \/>\n<meta property=\"og:locale\" content=\"ko_KR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"C# Coding Test Course, I Will Become the President of the Residents&#039; Association - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"og:description\" content=\"Problem Description The given problem is as follows. You need to write an algorithm to become the head of the residents&#8217; association for the number of floors in an apartment and the number of residents on each floor. The goal is to implement an algorithm that calculates the number of residents on a specific floor. &hellip; \ub354 \ubcf4\uae30 &quot;C# Coding Test Course, I Will Become the President of the Residents&#8217; Association&quot;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/atmokpo.com\/w\/33940\/\" \/>\n<meta property=\"og:site_name\" content=\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"article:published_time\" content=\"2024-11-01T09:22:13+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-11-01T10:54:47+00:00\" \/>\n<meta name=\"author\" content=\"root\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@bebubo4\" \/>\n<meta name=\"twitter:site\" content=\"@bebubo4\" \/>\n<meta name=\"twitter:label1\" content=\"\uae00\uc4f4\uc774\" \/>\n\t<meta name=\"twitter:data1\" content=\"root\" \/>\n\t<meta name=\"twitter:label2\" content=\"\uc608\uc0c1 \ub418\ub294 \ud310\ub3c5 \uc2dc\uac04\" \/>\n\t<meta name=\"twitter:data2\" content=\"3\ubd84\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/atmokpo.com\/w\/33940\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/33940\/\"},\"author\":{\"name\":\"root\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7\"},\"headline\":\"C# Coding Test Course, I Will Become the President of the Residents&#8217; Association\",\"datePublished\":\"2024-11-01T09:22:13+00:00\",\"dateModified\":\"2024-11-01T10:54:47+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/atmokpo.com\/w\/33940\/\"},\"wordCount\":416,\"publisher\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\"},\"articleSection\":[\"C# Coding Test Tutorials\"],\"inLanguage\":\"ko-KR\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/atmokpo.com\/w\/33940\/\",\"url\":\"https:\/\/atmokpo.com\/w\/33940\/\",\"name\":\"C# Coding Test Course, I Will Become the President of the Residents' Association - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#website\"},\"datePublished\":\"2024-11-01T09:22:13+00:00\",\"dateModified\":\"2024-11-01T10:54:47+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/atmokpo.com\/w\/33940\/#breadcrumb\"},\"inLanguage\":\"ko-KR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/atmokpo.com\/w\/33940\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/atmokpo.com\/w\/33940\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\ud648\",\"item\":\"https:\/\/atmokpo.com\/w\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"C# Coding Test Course, I Will Become the President of the Residents&#8217; Association\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/atmokpo.com\/w\/#website\",\"url\":\"https:\/\/atmokpo.com\/w\/\",\"name\":\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/atmokpo.com\/w\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"ko-KR\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\",\"name\":\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"url\":\"https:\/\/atmokpo.com\/w\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ko-KR\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png\",\"contentUrl\":\"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png\",\"width\":400,\"height\":400,\"caption\":\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\"},\"image\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/x.com\/bebubo4\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7\",\"name\":\"root\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ko-KR\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g\",\"caption\":\"root\"},\"sameAs\":[\"http:\/\/atmokpo.com\/w\"],\"url\":\"https:\/\/atmokpo.com\/w\/author\/root\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"C# Coding Test Course, I Will Become the President of the Residents' Association - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/atmokpo.com\/w\/33940\/","og_locale":"ko_KR","og_type":"article","og_title":"C# Coding Test Course, I Will Become the President of the Residents' Association - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","og_description":"Problem Description The given problem is as follows. You need to write an algorithm to become the head of the residents&#8217; association for the number of floors in an apartment and the number of residents on each floor. The goal is to implement an algorithm that calculates the number of residents on a specific floor. &hellip; \ub354 \ubcf4\uae30 \"C# Coding Test Course, I Will Become the President of the Residents&#8217; Association\"","og_url":"https:\/\/atmokpo.com\/w\/33940\/","og_site_name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","article_published_time":"2024-11-01T09:22:13+00:00","article_modified_time":"2024-11-01T10:54:47+00:00","author":"root","twitter_card":"summary_large_image","twitter_creator":"@bebubo4","twitter_site":"@bebubo4","twitter_misc":{"\uae00\uc4f4\uc774":"root","\uc608\uc0c1 \ub418\ub294 \ud310\ub3c5 \uc2dc\uac04":"3\ubd84"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/atmokpo.com\/w\/33940\/#article","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/33940\/"},"author":{"name":"root","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7"},"headline":"C# Coding Test Course, I Will Become the President of the Residents&#8217; Association","datePublished":"2024-11-01T09:22:13+00:00","dateModified":"2024-11-01T10:54:47+00:00","mainEntityOfPage":{"@id":"https:\/\/atmokpo.com\/w\/33940\/"},"wordCount":416,"publisher":{"@id":"https:\/\/atmokpo.com\/w\/#organization"},"articleSection":["C# Coding Test Tutorials"],"inLanguage":"ko-KR"},{"@type":"WebPage","@id":"https:\/\/atmokpo.com\/w\/33940\/","url":"https:\/\/atmokpo.com\/w\/33940\/","name":"C# Coding Test Course, I Will Become the President of the Residents' Association - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/#website"},"datePublished":"2024-11-01T09:22:13+00:00","dateModified":"2024-11-01T10:54:47+00:00","breadcrumb":{"@id":"https:\/\/atmokpo.com\/w\/33940\/#breadcrumb"},"inLanguage":"ko-KR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/atmokpo.com\/w\/33940\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/atmokpo.com\/w\/33940\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\ud648","item":"https:\/\/atmokpo.com\/w\/en\/"},{"@type":"ListItem","position":2,"name":"C# Coding Test Course, I Will Become the President of the Residents&#8217; Association"}]},{"@type":"WebSite","@id":"https:\/\/atmokpo.com\/w\/#website","url":"https:\/\/atmokpo.com\/w\/","name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","description":"","publisher":{"@id":"https:\/\/atmokpo.com\/w\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/atmokpo.com\/w\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"ko-KR"},{"@type":"Organization","@id":"https:\/\/atmokpo.com\/w\/#organization","name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","url":"https:\/\/atmokpo.com\/w\/","logo":{"@type":"ImageObject","inLanguage":"ko-KR","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/","url":"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png","contentUrl":"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png","width":400,"height":400,"caption":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8"},"image":{"@id":"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/x.com\/bebubo4"]},{"@type":"Person","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7","name":"root","image":{"@type":"ImageObject","inLanguage":"ko-KR","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g","caption":"root"},"sameAs":["http:\/\/atmokpo.com\/w"],"url":"https:\/\/atmokpo.com\/w\/author\/root\/"}]}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/33940","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/comments?post=33940"}],"version-history":[{"count":1,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/33940\/revisions"}],"predecessor-version":[{"id":33941,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/33940\/revisions\/33941"}],"wp:attachment":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/media?parent=33940"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/categories?post=33940"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/tags?post=33940"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}