<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>Jayharvey</title>
    <link>https://jayharvey.tistory.com/</link>
    <description>머신러닝/딥러닝 관련 글을 포스팅할 예정입니다 :)</description>
    <language>ko</language>
    <pubDate>Thu, 9 Jul 2026 12:05:14 +0900</pubDate>
    <generator>TISTORY</generator>
    <ttl>100</ttl>
    <managingEditor>jayharvey</managingEditor>
    <item>
      <title>백준 6359 만취한 상범</title>
      <link>https://jayharvey.tistory.com/31</link>
      <description>&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important; overflow:auto&quot;&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p style=&quot;color: rgb(0, 0, 0); font-family: &amp;quot;맑은 고딕&amp;quot;, sans-serif; text-align: center;&quot;&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;&lt;b&gt;&amp;lt;약수의 성질을 이용하는 법&amp;gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;br /&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin:auto; padding:0; border:none; background-color:#272727; border-radius:4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px; border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0; padding:0; word-break:normal; text-align:right; color:#aaa; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;2&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;3&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;4&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;5&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;6&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;7&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;8&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;9&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;10&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;11&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;12&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;13&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;14&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;15&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;16&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;17&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;18&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;19&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;20&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;21&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;22&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;23&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;24&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;25&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;26&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;27&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding:6px 0&quot;&gt;&lt;div style=&quot;margin:0; padding:0; color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#999999&quot;&gt;//&amp;nbsp;30분&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#999999&quot;&gt;//&amp;nbsp;d[i]&amp;nbsp;=&amp;nbsp;방의&amp;nbsp;갯수가&amp;nbsp;i개&amp;nbsp;일&amp;nbsp;때&amp;nbsp;열려있는&amp;nbsp;방의&amp;nbsp;갯수.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;#include&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;cstdio&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;using&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;namespace&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;std&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;a[&lt;span style=&quot;color:#c10aff&quot;&gt;101&lt;/span&gt;];&amp;nbsp;&lt;span style=&quot;color:#999999&quot;&gt;//&amp;nbsp;i번째&amp;nbsp;약수의&amp;nbsp;갯수&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;d[&lt;span style=&quot;color:#c10aff&quot;&gt;101&lt;/span&gt;];&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;main()&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;t;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;scanf&lt;/span&gt;(&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;%d&quot;&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;amp;&lt;/span&gt;t);&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;100&lt;/span&gt;;&amp;nbsp;i&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;)&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;j&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;;&amp;nbsp;j&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;*&lt;/span&gt;&amp;nbsp;j&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;i;&amp;nbsp;j&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;)&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;if&lt;/span&gt;&amp;nbsp;(i%j&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;)&amp;nbsp;a[i]&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;2&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;if&lt;/span&gt;&amp;nbsp;(j&lt;span style=&quot;color:#ff3399&quot;&gt;*&lt;/span&gt;j&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;i)&amp;nbsp;a[i]&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;100&lt;/span&gt;;&amp;nbsp;i&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;)&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;d[i]&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;d[i&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;]&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&amp;nbsp;(a[i]&amp;nbsp;%&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;2&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;&amp;nbsp;?&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;&amp;nbsp;:&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;);&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;while&lt;/span&gt;&amp;nbsp;(t&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;)&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;n;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;scanf&lt;/span&gt;(&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;%d&quot;&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;amp;&lt;/span&gt;n);&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;printf&lt;/span&gt;(&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;%d\n&quot;&lt;/span&gt;,&amp;nbsp;d[n]);&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;return&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;text-align:right; margin-top:-13px; margin-right:5px; font-size:9px; font-style:italic&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: rgb(79, 79, 79);&quot;&gt;Colored by Color Scripter&lt;/a&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align:bottom; padding:0 2px 4px 0&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; background-color: rgb(79, 79, 79); border-radius: 10px; padding: 1px;&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;/div&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;DP 문제&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;먼저 1~100까지 각각의 약수의 갯수를 구해준뒤 문제를 해결하였다.&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;약수의 갯수를 구하는 시간을 줄이기 위해 제곱수를 이용하였다.&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;약수의 성질을 이용하면 약수란 나누었을 때 0이 되게 하는 수 이므로&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;14번 줄&amp;nbsp;&amp;nbsp;&lt;span style=&quot;font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; text-align: start; white-space: pre; background-color: rgb(39, 39, 39); color: rgb(255, 51, 153);&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: rgb(240, 240, 240); font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; text-align: start; white-space: pre; background-color: rgb(39, 39, 39);&quot;&gt;&amp;nbsp;(i%j&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; text-align: start; white-space: pre; background-color: rgb(39, 39, 39); color: rgb(255, 51, 153);&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; text-align: start; white-space: pre; background-color: rgb(39, 39, 39); color: rgb(255, 51, 153);&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: rgb(240, 240, 240); font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; text-align: start; white-space: pre; background-color: rgb(39, 39, 39);&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; text-align: start; white-space: pre; background-color: rgb(39, 39, 39); color: rgb(193, 10, 255);&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: rgb(240, 240, 240); font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; text-align: start; white-space: pre; background-color: rgb(39, 39, 39);&quot;&gt;)&amp;nbsp;a[i]&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; text-align: start; white-space: pre; background-color: rgb(39, 39, 39); color: rgb(255, 51, 153);&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; text-align: start; white-space: pre; background-color: rgb(39, 39, 39); color: rgb(255, 51, 153);&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: rgb(240, 240, 240); font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; text-align: start; white-space: pre; background-color: rgb(39, 39, 39);&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; text-align: start; white-space: pre; background-color: rgb(39, 39, 39); color: rgb(193, 10, 255);&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color: rgb(240, 240, 240); font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; text-align: start; white-space: pre; background-color: rgb(39, 39, 39);&quot;&gt;;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;즉, i의 약수는 나누었을 때 0이 되는 j 이다. 그리고 약수의 성질을 잘 살펴보면&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;제곱수를 제외하고는 항상 짝을 이룬다.&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;예를 들어&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;10의 약수는 1, 2, 5, 10 인데 1은 10과 짝을 이루고 2는 5와 짝을 이루므로&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;10과 같이 제곱수가 아닌 경우에는 sqrt(10)까지만 연산을 하되 2씩 더해주면 된다.&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;====================================&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;여기서 제곱수는 예외가 되는데&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;1에서 10까지 약수의 갯수를 나열해 보면 다음과 같다.&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;1 2 3 4 5 6 7 8 9 10&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;1 2 2 3 2&amp;nbsp;4 2 4 3&amp;nbsp; 4&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;제곱수에 해당하는 1,4,9 만 약수의 갯수가 홀수 인 것을 알 수 있다.&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;그러므로 제곱수에 해당하는 수의 약수를 구한 뒤에는 다음과 같이 1을 빼준다.&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;15번 줄&amp;nbsp;&amp;nbsp;&lt;span style=&quot;font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; text-align: start; white-space: pre; background-color: rgb(39, 39, 39); color: rgb(255, 51, 153);&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: rgb(240, 240, 240); font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; text-align: start; white-space: pre; background-color: rgb(39, 39, 39);&quot;&gt;&amp;nbsp;(j&lt;/span&gt;&lt;span style=&quot;font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; text-align: start; white-space: pre; background-color: rgb(39, 39, 39); color: rgb(255, 51, 153);&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: rgb(240, 240, 240); font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; text-align: start; white-space: pre; background-color: rgb(39, 39, 39);&quot;&gt;j&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; text-align: start; white-space: pre; background-color: rgb(39, 39, 39); color: rgb(255, 51, 153);&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; text-align: start; white-space: pre; background-color: rgb(39, 39, 39); color: rgb(255, 51, 153);&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: rgb(240, 240, 240); font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; text-align: start; white-space: pre; background-color: rgb(39, 39, 39);&quot;&gt;&amp;nbsp;i)&amp;nbsp;a[i]&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; text-align: start; white-space: pre; background-color: rgb(39, 39, 39); color: rgb(255, 51, 153);&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; text-align: start; white-space: pre; background-color: rgb(39, 39, 39); color: rgb(255, 51, 153);&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: rgb(240, 240, 240); font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; text-align: start; white-space: pre; background-color: rgb(39, 39, 39);&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; text-align: start; white-space: pre; background-color: rgb(39, 39, 39); color: rgb(193, 10, 255);&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: rgb(240, 240, 240); font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; text-align: start; white-space: pre; background-color: rgb(39, 39, 39);&quot;&gt;;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;각각의 약수의 갯수를&amp;nbsp;구한 이후 dp의 성질을 이용하면 다음과 같다.&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;19번 줄&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: rgb(240, 240, 240); font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; white-space: pre; background-color: rgb(39, 39, 39);&quot;&gt;d[i]&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; white-space: pre; background-color: rgb(39, 39, 39); color: rgb(255, 51, 153);&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: rgb(240, 240, 240); font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; white-space: pre; background-color: rgb(39, 39, 39);&quot;&gt;&amp;nbsp;d[i&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; white-space: pre; background-color: rgb(39, 39, 39); color: rgb(255, 51, 153);&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: rgb(240, 240, 240); font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; white-space: pre; background-color: rgb(39, 39, 39);&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; white-space: pre; background-color: rgb(39, 39, 39); color: rgb(193, 10, 255);&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: rgb(240, 240, 240); font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; white-space: pre; background-color: rgb(39, 39, 39);&quot;&gt;]&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; white-space: pre; background-color: rgb(39, 39, 39); color: rgb(255, 51, 153);&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: rgb(240, 240, 240); font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; white-space: pre; background-color: rgb(39, 39, 39);&quot;&gt;&amp;nbsp;(a[i]&amp;nbsp;%&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; white-space: pre; background-color: rgb(39, 39, 39); color: rgb(193, 10, 255);&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color: rgb(240, 240, 240); font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; white-space: pre; background-color: rgb(39, 39, 39);&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; white-space: pre; background-color: rgb(39, 39, 39); color: rgb(255, 51, 153);&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; white-space: pre; background-color: rgb(39, 39, 39); color: rgb(255, 51, 153);&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: rgb(240, 240, 240); font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; white-space: pre; background-color: rgb(39, 39, 39);&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; white-space: pre; background-color: rgb(39, 39, 39); color: rgb(193, 10, 255);&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: rgb(240, 240, 240); font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; white-space: pre; background-color: rgb(39, 39, 39);&quot;&gt;&amp;nbsp;?&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; white-space: pre; background-color: rgb(39, 39, 39); color: rgb(193, 10, 255);&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: rgb(240, 240, 240); font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; white-space: pre; background-color: rgb(39, 39, 39);&quot;&gt;&amp;nbsp;:&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; white-space: pre; background-color: rgb(39, 39, 39); color: rgb(193, 10, 255);&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: rgb(240, 240, 240); font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; white-space: pre; background-color: rgb(39, 39, 39);&quot;&gt;);&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;d[i] = i-1번째 까지 열린방의 갯수 + 현재 방의 상태&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;i&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;※ 정리해보면,&lt;/span&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;&amp;nbsp;1~10까지 직접 나열하여 방이 열려있는 유무를 확인해보면&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;&lt;i&gt;최종적으로 &quot;약수의 갯수&quot;가 짝수일 때 닫혀있고, 홀수일 때 열려있다는 것을 알수 있다.&lt;/i&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;&lt;i&gt;그리고 약수의 갯수가 짝수라는 것은 해당 수가 제곱수라는 뜻이다.&lt;/i&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;&amp;lt;DP를 이용한 일반적인 풀이&lt;/span&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;법&amp;gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important; overflow:auto&quot;&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin:auto; padding:0; border:none; background-color:#272727; border-radius:4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px; border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0; padding:0; word-break:normal; text-align:right; color:#aaa; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;2&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;3&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;4&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;5&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;6&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;7&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;8&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;9&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;10&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;11&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;12&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;13&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;14&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;15&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;16&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;17&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;18&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;19&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;20&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;21&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;22&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;23&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;24&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;25&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;26&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding:6px 0&quot;&gt;&lt;div style=&quot;margin:0; padding:0; color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#999999&quot;&gt;//&amp;nbsp;30분&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#999999&quot;&gt;//&amp;nbsp;d[i]&amp;nbsp;=&amp;nbsp;방의&amp;nbsp;갯수가&amp;nbsp;i개&amp;nbsp;일&amp;nbsp;때&amp;nbsp;열려있는&amp;nbsp;방의&amp;nbsp;갯수.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;#include&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;cstdio&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;using&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;namespace&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;std&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;main()&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;t;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;scanf&lt;/span&gt;(&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;%d&quot;&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;amp;&lt;/span&gt;t);&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;while&lt;/span&gt;&amp;nbsp;(t&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;)&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;n;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;scanf&lt;/span&gt;(&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;%d&quot;&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;amp;&lt;/span&gt;n);&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;d[&lt;span style=&quot;color:#c10aff&quot;&gt;101&lt;/span&gt;]&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;{&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;&amp;nbsp;};&amp;nbsp;&lt;span style=&quot;color:#999999&quot;&gt;//&amp;nbsp;모든&amp;nbsp;원소를&amp;nbsp;0으로&amp;nbsp;초기화&amp;nbsp;시킴.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;n;&amp;nbsp;i&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;)&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;j&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;*&lt;/span&gt;&amp;nbsp;j&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;n;&amp;nbsp;j&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;)&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;if&lt;/span&gt;&amp;nbsp;(d[i&lt;span style=&quot;color:#ff3399&quot;&gt;*&lt;/span&gt;j])&amp;nbsp;d[i&lt;span style=&quot;color:#ff3399&quot;&gt;*&lt;/span&gt;j]&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;!&lt;/span&gt;d[i&lt;span style=&quot;color:#ff3399&quot;&gt;*&lt;/span&gt;j];&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;else&lt;/span&gt;&amp;nbsp;d[i&lt;span style=&quot;color:#ff3399&quot;&gt;*&lt;/span&gt;j]&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;!&lt;/span&gt;d[i&lt;span style=&quot;color:#ff3399&quot;&gt;*&lt;/span&gt;j];&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;sum&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;n;&amp;nbsp;i&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;)&amp;nbsp;sum&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;d[i];&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;printf&lt;/span&gt;(&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;%d\n&quot;&lt;/span&gt;,&amp;nbsp;sum);&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;return&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;text-align:right; margin-top:-13px; margin-right:5px; font-size:9px; font-style:italic&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: rgb(79, 79, 79);&quot;&gt;Colored by Color Scripter&lt;/a&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align:bottom; padding:0 2px 4px 0&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; background-color: rgb(79, 79, 79); border-radius: 10px; padding: 1px;&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>Algorithm</category>
      <author>jayharvey</author>
      <guid isPermaLink="true">https://jayharvey.tistory.com/31</guid>
      <comments>https://jayharvey.tistory.com/31#entry31comment</comments>
      <pubDate>Fri, 18 May 2018 22:41:20 +0900</pubDate>
    </item>
    <item>
      <title>백준 1309 동물원</title>
      <link>https://jayharvey.tistory.com/30</link>
      <description>&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important; overflow:auto&quot;&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin:auto; padding:0; border:none; background-color:#272727; border-radius:4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px; border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0; padding:0; word-break:normal; text-align:right; color:#aaa; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;2&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;3&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;4&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;5&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;6&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;7&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;8&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;9&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;10&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;11&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;12&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;13&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;14&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;15&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;16&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;17&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;18&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;19&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;20&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;21&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;22&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;23&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding:6px 0&quot;&gt;&lt;div style=&quot;margin:0; padding:0; color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#999999&quot;&gt;//&amp;nbsp;다시&amp;nbsp;풀기(힌트&amp;nbsp;얻어서&amp;nbsp;품)&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#999999&quot;&gt;//&amp;nbsp;d[i][0]&amp;nbsp;=&amp;nbsp;2*i에&amp;nbsp;사자를&amp;nbsp;배치하되&amp;nbsp;마지막&amp;nbsp;칸에는&amp;nbsp;배치하지&amp;nbsp;않는&amp;nbsp;경우&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#999999&quot;&gt;//&amp;nbsp;d[i][1]&amp;nbsp;=&amp;nbsp;2*i에&amp;nbsp;사자를&amp;nbsp;배치하되&amp;nbsp;마지막&amp;nbsp;칸&amp;nbsp;왼쪽에&amp;nbsp;배치하는&amp;nbsp;경우&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#999999&quot;&gt;//&amp;nbsp;d[i][2]&amp;nbsp;=&amp;nbsp;2*i에&amp;nbsp;사자를&amp;nbsp;배치하되&amp;nbsp;마지막&amp;nbsp;칸&amp;nbsp;오른쪽에&amp;nbsp;배치하는&amp;nbsp;경우&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;#include&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;cstdio&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;using&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;namespace&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;std&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;n,&amp;nbsp;d[&lt;span style=&quot;color:#c10aff&quot;&gt;100001&lt;/span&gt;][&lt;span style=&quot;color:#c10aff&quot;&gt;3&lt;/span&gt;];&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;main()&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;scanf&lt;/span&gt;(&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;%d&quot;&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;amp;&lt;/span&gt;n);&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;d[&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;]&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;n;&amp;nbsp;i&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;)&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;d[i][&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;]&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;(d[i&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;][&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;]&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&amp;nbsp;d[i&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;][&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;]&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&amp;nbsp;d[i&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;][&lt;span style=&quot;color:#c10aff&quot;&gt;2&lt;/span&gt;])&amp;nbsp;%&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;9901&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;d[i][&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;]&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;(d[i&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;][&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;]&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&amp;nbsp;d[i&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;][&lt;span style=&quot;color:#c10aff&quot;&gt;2&lt;/span&gt;])&amp;nbsp;%&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;9901&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;d[i][&lt;span style=&quot;color:#c10aff&quot;&gt;2&lt;/span&gt;]&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;(d[i&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;][&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;]&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&amp;nbsp;d[i&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;][&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;])&amp;nbsp;%&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;9901&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;printf&lt;/span&gt;(&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;%d\n&quot;&lt;/span&gt;,&amp;nbsp;(d[n][&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;]&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&amp;nbsp;d[n][&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;]&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&amp;nbsp;d[n][&lt;span style=&quot;color:#c10aff&quot;&gt;2&lt;/span&gt;])&amp;nbsp;%&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;9901&lt;/span&gt;);&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;return&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;text-align:right; margin-top:-13px; margin-right:5px; font-size:9px; font-style:italic&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: rgb(79, 79, 79);&quot;&gt;Colored by Color Scripter&lt;/a&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align:bottom; padding:0 2px 4px 0&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; background-color: rgb(79, 79, 79); border-radius: 10px; padding: 1px;&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>Algorithm</category>
      <author>jayharvey</author>
      <guid isPermaLink="true">https://jayharvey.tistory.com/30</guid>
      <comments>https://jayharvey.tistory.com/30#entry30comment</comments>
      <pubDate>Fri, 18 May 2018 19:05:27 +0900</pubDate>
    </item>
    <item>
      <title>백준 1965 상자넣기</title>
      <link>https://jayharvey.tistory.com/29</link>
      <description>&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important; overflow:auto&quot;&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin:auto; padding:0; border:none; background-color:#272727; border-radius:4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px; border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0; padding:0; word-break:normal; text-align:right; color:#aaa; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;2&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;3&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;4&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;5&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;6&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;7&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;8&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;9&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;10&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;11&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;12&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;13&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;14&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;15&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;16&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;17&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;18&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;19&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;20&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;21&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;22&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;23&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;24&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;25&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;26&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;27&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;28&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;29&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;30&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;31&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;32&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;33&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;34&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;35&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding:6px 0&quot;&gt;&lt;div style=&quot;margin:0; padding:0; color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#999999&quot;&gt;//&amp;nbsp;다시&amp;nbsp;풀기&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#999999&quot;&gt;//&amp;nbsp;D[i]를&amp;nbsp;뭘로&amp;nbsp;놓냐가&amp;nbsp;핵심&amp;nbsp;!&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#999999&quot;&gt;//&amp;nbsp;처음&amp;nbsp;접근할&amp;nbsp;때&amp;nbsp;D[i]를&amp;nbsp;A[i]까지&amp;nbsp;검사했을&amp;nbsp;때&amp;nbsp;가장&amp;nbsp;긴&amp;nbsp;부분&amp;nbsp;수열의&amp;nbsp;길이&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#999999&quot;&gt;//&amp;nbsp;로&amp;nbsp;설정했더니&amp;nbsp;안&amp;nbsp;풀림.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#999999&quot;&gt;//&amp;nbsp;D[i]&amp;nbsp;=&amp;nbsp;A[1],&amp;nbsp;,&amp;nbsp;,&amp;nbsp;A[i]&amp;nbsp;까지&amp;nbsp;수열이&amp;nbsp;있을&amp;nbsp;때,&amp;nbsp;A[i]을&amp;nbsp;마지막으로&amp;nbsp;하는&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#999999&quot;&gt;//&amp;nbsp;가장&amp;nbsp;긴&amp;nbsp;증가하는&amp;nbsp;부분&amp;nbsp;수열의&amp;nbsp;길이.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;#include&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;cstdio&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;#include&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;algorithm&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#999999&quot;&gt;//&amp;nbsp;*max_element()를&amp;nbsp;이용하기&amp;nbsp;위함.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;#include&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;vector&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;using&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;namespace&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;std&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;main()&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;n;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;scanf&lt;/span&gt;(&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;%d&quot;&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;amp;&lt;/span&gt;n);&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;vector&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;a(n);&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&amp;nbsp;n;&amp;nbsp;i&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;)&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;scanf&lt;/span&gt;(&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;%d&quot;&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;amp;&lt;/span&gt;a[i]);&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;vector&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;d(n);&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&amp;nbsp;n;&amp;nbsp;i&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;)&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;d[i]&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;;&amp;nbsp;&lt;span style=&quot;color:#999999&quot;&gt;//&amp;nbsp;자기자신만&amp;nbsp;있을&amp;nbsp;경우&amp;nbsp;1이므로.&amp;nbsp;최소&amp;nbsp;1이됨.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;j&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;;&amp;nbsp;j&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&amp;nbsp;i;&amp;nbsp;j&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;)&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#999999&quot;&gt;//&amp;nbsp;현재&amp;nbsp;d[i]가&amp;nbsp;d[j]&amp;nbsp;+&amp;nbsp;1보다&amp;nbsp;크거나&amp;nbsp;같다면&amp;nbsp;대치시킬&amp;nbsp;필요&amp;nbsp;x&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;if&lt;/span&gt;&amp;nbsp;(a[j]&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&amp;nbsp;a[i]&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;amp;&lt;/span&gt;&amp;nbsp;d[j]&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;d[i])&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;d[i]&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;d[j]&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;printf&lt;/span&gt;(&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;%d\n&quot;&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;*&lt;/span&gt;max_element(d.&lt;span style=&quot;color:#4be6fa&quot;&gt;begin&lt;/span&gt;(),&amp;nbsp;d.&lt;span style=&quot;color:#4be6fa&quot;&gt;end&lt;/span&gt;()));&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;return&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;}&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;text-align:right; margin-top:-13px; margin-right:5px; font-size:9px; font-style:italic&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: rgb(79, 79, 79);&quot;&gt;Colored by Color Scripter&lt;/a&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align:bottom; padding:0 2px 4px 0&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; background-color: rgb(79, 79, 79); border-radius: 10px; padding: 1px;&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;이 문제를 처음보자마자 든 생각은&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&quot; 11053 가장 긴 증가하는 부분 수열 문제와 똑같다 &quot; 이다. 실제로 그렇다.&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;하지만 알고리즘을 한 달만에 다시 하려다 보니 접근법이 도저히 떠오르지 않고&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;오래 고민할 시간도 없어서 전에 풀었던 11053 문제 코드 보고 풀었다...&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;간단히 리뷰해보면,&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;DP 문제에서는 d[]를 뭘로 정의하느냐가 가장 핵심이다.&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;그리고 배열로 선언하지 않고 vector로 선언해야&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;span style=&quot;font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; text-align: start; white-space: pre; background-color: rgb(39, 39, 39); color: rgb(255, 51, 153);&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: rgb(240, 240, 240); font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; text-align: start; white-space: pre; background-color: rgb(39, 39, 39);&quot;&gt;max_element(d.&lt;/span&gt;&lt;span style=&quot;font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; text-align: start; white-space: pre; background-color: rgb(39, 39, 39); color: rgb(75, 230, 250);&quot;&gt;begin&lt;/span&gt;&lt;span style=&quot;color: rgb(240, 240, 240); font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; text-align: start; white-space: pre; background-color: rgb(39, 39, 39);&quot;&gt;(),&amp;nbsp;d.&lt;/span&gt;&lt;span style=&quot;font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; text-align: start; white-space: pre; background-color: rgb(39, 39, 39); color: rgb(75, 230, 250);&quot;&gt;end&lt;/span&gt;&lt;span style=&quot;color: rgb(240, 240, 240); font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; text-align: start; white-space: pre; background-color: rgb(39, 39, 39);&quot;&gt;())&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;위 함수를 이용하여 배열 원소들 중에 최댓값을 쉽게 찾을 수 있다.&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>Algorithm</category>
      <author>jayharvey</author>
      <guid isPermaLink="true">https://jayharvey.tistory.com/29</guid>
      <comments>https://jayharvey.tistory.com/29#entry29comment</comments>
      <pubDate>Fri, 18 May 2018 18:06:51 +0900</pubDate>
    </item>
    <item>
      <title>백준 11051 이항 계수 2</title>
      <link>https://jayharvey.tistory.com/28</link>
      <description>&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important; overflow:auto&quot;&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin:auto; padding:0; border:none; background-color:#272727; border-radius:4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px; border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0; padding:0; word-break:normal; text-align:right; color:#aaa; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;2&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;3&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;4&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;5&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;6&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;7&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;8&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;9&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;10&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;11&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;12&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;13&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;14&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;15&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;16&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;17&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;18&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;19&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;20&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;21&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;22&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;23&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding:6px 0&quot;&gt;&lt;div style=&quot;margin:0; padding:0; color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#999999&quot;&gt;//&amp;nbsp;18분&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;#include&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;cstdio&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;using&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;namespace&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;std&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;d[&lt;span style=&quot;color:#c10aff&quot;&gt;1001&lt;/span&gt;][&lt;span style=&quot;color:#c10aff&quot;&gt;1001&lt;/span&gt;];&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#999999&quot;&gt;//&amp;nbsp;nCr&amp;nbsp;=&amp;nbsp;n-1Cr&amp;nbsp;+&amp;nbsp;n-1Cr-1&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;dp(&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;n,&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;k)&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;if&lt;/span&gt;&amp;nbsp;(d[n][k]&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;)&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;return&lt;/span&gt;&amp;nbsp;d[n][k];&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;if&lt;/span&gt;&amp;nbsp;(n&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&amp;nbsp;k)&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;return&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;else&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;if&lt;/span&gt;&amp;nbsp;(n&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;k&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;|&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;|&lt;/span&gt;&amp;nbsp;k&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;)&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;return&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;else&lt;/span&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;return&lt;/span&gt;&amp;nbsp;d[n][k]&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;(dp(n&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;,&amp;nbsp;k)&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&amp;nbsp;dp(n&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;,&amp;nbsp;k&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;))&amp;nbsp;%&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;10007&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;main()&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;n,&amp;nbsp;k;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;scanf&lt;/span&gt;(&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;%d&amp;nbsp;%d&quot;&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;amp;&lt;/span&gt;n,&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;amp;&lt;/span&gt;k);&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;printf&lt;/span&gt;(&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;%d\n&quot;&lt;/span&gt;,&amp;nbsp;dp(n,&amp;nbsp;k));&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;return&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;text-align:right; margin-top:-13px; margin-right:5px; font-size:9px; font-style:italic&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: rgb(79, 79, 79);&quot;&gt;Colored by Color Scripter&lt;/a&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align:bottom; padding:0 2px 4px 0&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; background-color: rgb(79, 79, 79); border-radius: 10px; padding: 1px;&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;DP를 이용한 조합 문제 풀이&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;예외조건을 잘 처리해줄 것!&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>Algorithm</category>
      <author>jayharvey</author>
      <guid isPermaLink="true">https://jayharvey.tistory.com/28</guid>
      <comments>https://jayharvey.tistory.com/28#entry28comment</comments>
      <pubDate>Fri, 18 May 2018 17:22:01 +0900</pubDate>
    </item>
    <item>
      <title>백준 4344 평균은 넘겠지</title>
      <link>https://jayharvey.tistory.com/27</link>
      <description>&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important; overflow:auto&quot;&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin:auto; padding:0; border:none; background-color:#272727; border-radius:4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px; border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0; padding:0; word-break:normal; text-align:right; color:#aaa; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;2&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;3&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;4&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;5&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;6&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;7&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;8&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;9&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;10&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;11&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;12&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;13&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;14&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;15&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;16&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;17&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;18&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;19&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;20&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;21&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;22&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;23&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;24&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;25&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;26&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;27&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding:6px 0&quot;&gt;&lt;div style=&quot;margin:0; padding:0; color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;#include&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;cstdio&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;#include&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;cstring&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;using&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;namespace&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;std&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;score[&lt;span style=&quot;color:#c10aff&quot;&gt;1000&lt;/span&gt;];&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;main()&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;c;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;scanf&lt;/span&gt;(&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;%d&quot;&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;amp;&lt;/span&gt;c);&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;while&lt;/span&gt;&amp;nbsp;(c&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;)&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;memset(score,&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;sizeof&lt;/span&gt;(score));&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;n&amp;nbsp;,&amp;nbsp;sum&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;scanf&lt;/span&gt;(&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;%d&quot;&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;amp;&lt;/span&gt;n);&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&amp;nbsp;n;&amp;nbsp;i&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;)&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;scanf&lt;/span&gt;(&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;%d&quot;&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;amp;&lt;/span&gt;score[i]);&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;sum&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;score[i];&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;double&lt;/span&gt;&amp;nbsp;avg&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color:#4be6fa&quot;&gt;double&lt;/span&gt;)sum&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;&amp;nbsp;n;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;num&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&amp;nbsp;n;&amp;nbsp;i&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;)&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;if&lt;/span&gt;&amp;nbsp;(score[i]&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;avg)&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;num&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;printf&lt;/span&gt;(&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;%.3f%%\n&quot;&lt;/span&gt;,&amp;nbsp;(&lt;span style=&quot;color:#4be6fa&quot;&gt;double&lt;/span&gt;)num&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;&amp;nbsp;n&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;*&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;100&lt;/span&gt;);&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;return&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;text-align:right; margin-top:-13px; margin-right:5px; font-size:9px; font-style:italic&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: rgb(79, 79, 79);&quot;&gt;Colored by Color Scripter&lt;/a&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align:bottom; padding:0 2px 4px 0&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; background-color: rgb(79, 79, 79); border-radius: 10px; padding: 1px;&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;자료형에 약해&amp;nbsp;항상 피해다녔는데 이번에 풀어보았다&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;매 테스트케이스마다 배열 공간을 새로이 할당하는 것보다는&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;0으로 초기화 시켜주는게 나을거 같아 memset()을 이용하였다.&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;(But, 둘 다 해본 결과 메모리 사용량이나 시간에 차이가 없다. 아마 새로이 할당하는 게 아니라 변수명으로 덮어씌우는 듯.)&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;핵심은&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;나누었을 때 소숫점이하 자리까지 얻으려면 다음과 같이 sum에 명시적 형변환을 해줘야 한다.&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; text-align: start; white-space: pre; background-color: rgb(39, 39, 39); color: rgb(75, 230, 250);&quot;&gt;double&lt;/span&gt;&lt;span style=&quot;color: rgb(240, 240, 240); font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; text-align: start; white-space: pre; background-color: rgb(39, 39, 39);&quot;&gt;&amp;nbsp;avg&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; text-align: start; white-space: pre; background-color: rgb(39, 39, 39); color: rgb(255, 51, 153);&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: rgb(240, 240, 240); font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; text-align: start; white-space: pre; background-color: rgb(39, 39, 39);&quot;&gt;&amp;nbsp;(&lt;/span&gt;&lt;span style=&quot;font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; text-align: start; white-space: pre; background-color: rgb(39, 39, 39); color: rgb(75, 230, 250);&quot;&gt;double&lt;/span&gt;&lt;span style=&quot;color: rgb(240, 240, 240); font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; text-align: start; white-space: pre; background-color: rgb(39, 39, 39);&quot;&gt;)sum&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; text-align: start; white-space: pre; background-color: rgb(39, 39, 39); color: rgb(255, 51, 153);&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: rgb(240, 240, 240); font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; text-align: start; white-space: pre; background-color: rgb(39, 39, 39);&quot;&gt;&amp;nbsp;n;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;그리고&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;소숫점 이하 셋째자리까지 출력하고 싶다면 %.3f 를 써줘야 하고&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;그 뒤에 % 문자를 출력하고 싶다면 %% 를 써줘야 한다.&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;span style=&quot;font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; text-align: start; white-space: pre; background-color: rgb(39, 39, 39); color: rgb(75, 230, 250);&quot;&gt;printf&lt;/span&gt;&lt;span style=&quot;color: rgb(240, 240, 240); font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; text-align: start; white-space: pre; background-color: rgb(39, 39, 39);&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; text-align: start; white-space: pre; background-color: rgb(39, 39, 39); color: rgb(255, 213, 0);&quot;&gt;&quot;%.3f%%\n&quot;&lt;/span&gt;&lt;span style=&quot;color: rgb(240, 240, 240); font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; text-align: start; white-space: pre; background-color: rgb(39, 39, 39);&quot;&gt;,&amp;nbsp;(&lt;/span&gt;&lt;span style=&quot;font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; text-align: start; white-space: pre; background-color: rgb(39, 39, 39); color: rgb(75, 230, 250);&quot;&gt;double&lt;/span&gt;&lt;span style=&quot;color: rgb(240, 240, 240); font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; text-align: start; white-space: pre; background-color: rgb(39, 39, 39);&quot;&gt;)num&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; text-align: start; white-space: pre; background-color: rgb(39, 39, 39); color: rgb(255, 51, 153);&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: rgb(240, 240, 240); font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; text-align: start; white-space: pre; background-color: rgb(39, 39, 39);&quot;&gt;&amp;nbsp;n&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; text-align: start; white-space: pre; background-color: rgb(39, 39, 39); color: rgb(255, 51, 153);&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: rgb(240, 240, 240); font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; text-align: start; white-space: pre; background-color: rgb(39, 39, 39);&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; text-align: start; white-space: pre; background-color: rgb(39, 39, 39); color: rgb(193, 10, 255);&quot;&gt;100&lt;/span&gt;&lt;span style=&quot;color: rgb(240, 240, 240); font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; text-align: start; white-space: pre; background-color: rgb(39, 39, 39);&quot;&gt;);&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>Algorithm</category>
      <author>jayharvey</author>
      <guid isPermaLink="true">https://jayharvey.tistory.com/27</guid>
      <comments>https://jayharvey.tistory.com/27#entry27comment</comments>
      <pubDate>Fri, 18 May 2018 16:07:49 +0900</pubDate>
    </item>
    <item>
      <title>백준 9251 LCS</title>
      <link>https://jayharvey.tistory.com/26</link>
      <description>&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important; overflow:auto&quot;&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin:auto; padding:0; border:none; background-color:#272727; border-radius:4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px; border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0; padding:0; word-break:normal; text-align:right; color:#aaa; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;2&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;3&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;4&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;5&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;6&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;7&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;8&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;9&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;10&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;11&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;12&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;13&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;14&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;15&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;16&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;17&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;18&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;19&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;20&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;21&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;22&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;23&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;24&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;25&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;26&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;27&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding:6px 0&quot;&gt;&lt;div style=&quot;margin:0; padding:0; color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#999999&quot;&gt;//&amp;nbsp;다시&amp;nbsp;풀기&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;#include&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;iostream&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;#include&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;cstdio&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;#include&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;string&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;#include&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;cstring&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;#include&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;algorithm&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;using&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;namespace&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;std&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;string&lt;/span&gt;&amp;nbsp;s1,&amp;nbsp;s2;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;d[&lt;span style=&quot;color:#c10aff&quot;&gt;1001&lt;/span&gt;][&lt;span style=&quot;color:#c10aff&quot;&gt;1001&lt;/span&gt;]&amp;nbsp;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;dp(&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;a,&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;b)&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;if&lt;/span&gt;&amp;nbsp;(a&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;|&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;|&lt;/span&gt;&amp;nbsp;b&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;)&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;return&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;if&lt;/span&gt;&amp;nbsp;(d[a][b]&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;!&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;)&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;return&lt;/span&gt;&amp;nbsp;d[a][b];&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;return&lt;/span&gt;&amp;nbsp;d[a][b]&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;max({&amp;nbsp;dp(a&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;,&amp;nbsp;b),&amp;nbsp;dp(a,&amp;nbsp;b&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;),&amp;nbsp;dp(a&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;,&amp;nbsp;b&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;)&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&amp;nbsp;(s1[a]&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;s2[b])&amp;nbsp;});&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;main()&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;cin&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;s1;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;cin&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;s2;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;memset(d,&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;sizeof&lt;/span&gt;(d));&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;printf&lt;/span&gt;(&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;%d\n&quot;&lt;/span&gt;,&amp;nbsp;dp(s1.&lt;span style=&quot;color:#4be6fa&quot;&gt;size&lt;/span&gt;()&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;,&amp;nbsp;s2.&lt;span style=&quot;color:#4be6fa&quot;&gt;size&lt;/span&gt;()&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;));&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;return&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;text-align:right; margin-top:-13px; margin-right:5px; font-size:9px; font-style:italic&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: rgb(79, 79, 79);&quot;&gt;Colored by Color Scripter&lt;/a&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align:bottom; padding:0 2px 4px 0&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; background-color: rgb(79, 79, 79); border-radius: 10px; padding: 1px;&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;내겐 상당히 까다로웠던 문제.&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;Top-Down 방식의 DP로 접근.&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;&lt;b&gt;1. string으로 문자열 입력받기&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;string대신에 char s1[1001]로 입력받을 경우 문자열 길이를 구하기가 까다로워진다.&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;string을 사용하면&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt;A. 문자열 입력받기 편하고&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; white-space: pre; background-color: rgb(39, 39, 39); color: rgb(75, 230, 250); font-size: 11pt;&quot;&gt;cin&lt;/span&gt;&lt;span style=&quot;color: rgb(240, 240, 240); font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; white-space: pre; background-color: rgb(39, 39, 39); font-size: 11pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; white-space: pre; background-color: rgb(39, 39, 39); color: rgb(255, 51, 153); font-size: 11pt;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; white-space: pre; background-color: rgb(39, 39, 39); color: rgb(255, 51, 153); font-size: 11pt;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: rgb(240, 240, 240); font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; white-space: pre; background-color: rgb(39, 39, 39); font-size: 11pt;&quot;&gt;&amp;nbsp;s1;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt;B. 배열처럼 인덱스로 접근할 수 있고&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: rgb(240, 240, 240); font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; white-space: pre; background-color: rgb(39, 39, 39); font-size: 11pt;&quot;&gt;s1[a]&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; white-space: pre; background-color: rgb(39, 39, 39); color: rgb(255, 51, 153); font-size: 11pt;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; white-space: pre; background-color: rgb(39, 39, 39); color: rgb(255, 51, 153); font-size: 11pt;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: rgb(240, 240, 240); font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; white-space: pre; background-color: rgb(39, 39, 39); font-size: 11pt;&quot;&gt;&amp;nbsp;s2[b]&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;span style=&quot;font-size: 11pt;&quot;&gt;C. 길이를 쉽게 구할 수&amp;nbsp;있다.&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: rgb(240, 240, 240); font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; white-space: pre; background-color: rgb(39, 39, 39); font-size: 11pt;&quot;&gt;s1.&lt;/span&gt;&lt;span style=&quot;font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; white-space: pre; background-color: rgb(39, 39, 39); color: rgb(75, 230, 250); font-size: 11pt;&quot;&gt;size&lt;/span&gt;&lt;span style=&quot;color: rgb(240, 240, 240); font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; white-space: pre; background-color: rgb(39, 39, 39); font-size: 11pt;&quot;&gt;()&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;&lt;b&gt;2. memoization을 0이 아닌 -1로 초기화하기.&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;span style=&quot;font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; text-align: start; white-space: pre; background-color: rgb(39, 39, 39); color: rgb(75, 230, 250);&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color: rgb(240, 240, 240); font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; text-align: start; white-space: pre; background-color: rgb(39, 39, 39);&quot;&gt;&amp;nbsp;d[&lt;/span&gt;&lt;span style=&quot;font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; text-align: start; white-space: pre; background-color: rgb(39, 39, 39); color: rgb(193, 10, 255);&quot;&gt;1001&lt;/span&gt;&lt;span style=&quot;color: rgb(240, 240, 240); font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; text-align: start; white-space: pre; background-color: rgb(39, 39, 39);&quot;&gt;][&lt;/span&gt;&lt;span style=&quot;font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; text-align: start; white-space: pre; background-color: rgb(39, 39, 39); color: rgb(193, 10, 255);&quot;&gt;1001&lt;/span&gt;&lt;span style=&quot;color: rgb(240, 240, 240); font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; text-align: start; white-space: pre; background-color: rgb(39, 39, 39);&quot;&gt;]&amp;nbsp;;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;span style=&quot;color: rgb(240, 240, 240); font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; text-align: start; white-space: pre; background-color: rgb(39, 39, 39);&quot;&gt;memset(d,&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; text-align: start; white-space: pre; background-color: rgb(39, 39, 39); color: rgb(255, 51, 153);&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; text-align: start; white-space: pre; background-color: rgb(39, 39, 39); color: rgb(193, 10, 255);&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: rgb(240, 240, 240); font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; text-align: start; white-space: pre; background-color: rgb(39, 39, 39);&quot;&gt;,&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; text-align: start; white-space: pre; background-color: rgb(39, 39, 39); color: rgb(255, 51, 153);&quot;&gt;sizeof&lt;/span&gt;&lt;span style=&quot;color: rgb(240, 240, 240); font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; text-align: start; white-space: pre; background-color: rgb(39, 39, 39);&quot;&gt;(d));&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;cstring 라이브러리를 include하여 memset으로 -1로 초기화 해준다.&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;보통 배열을 0으로 초기화하지만 이 경우에는 d[i][j] 가 0인 경우가 필요하므로&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;한번도 참조하지 않았다는 의미에서 -1로 초기화 해준다.&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;3. max() 로 삼중 비교하기&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;max()는 두개의 인자를 받으므로 두 수만 비교가능한 것으로 알고 있다.&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;물론, max()를 겹쳐서 삼중 비교가 가능하지만 다음과 같이 {} 안에 써주면 삼중비교가 가능하다.&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;span style=&quot;color: rgb(240, 240, 240); font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; text-align: start; white-space: pre; background-color: rgb(39, 39, 39);&quot;&gt;max({&amp;nbsp;dp(a&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; text-align: start; white-space: pre; background-color: rgb(39, 39, 39); color: rgb(255, 51, 153);&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: rgb(240, 240, 240); font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; text-align: start; white-space: pre; background-color: rgb(39, 39, 39);&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; text-align: start; white-space: pre; background-color: rgb(39, 39, 39); color: rgb(193, 10, 255);&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: rgb(240, 240, 240); font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; text-align: start; white-space: pre; background-color: rgb(39, 39, 39);&quot;&gt;,&amp;nbsp;b),&amp;nbsp;dp(a,&amp;nbsp;b&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; text-align: start; white-space: pre; background-color: rgb(39, 39, 39); color: rgb(255, 51, 153);&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: rgb(240, 240, 240); font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; text-align: start; white-space: pre; background-color: rgb(39, 39, 39);&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; text-align: start; white-space: pre; background-color: rgb(39, 39, 39); color: rgb(193, 10, 255);&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: rgb(240, 240, 240); font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; text-align: start; white-space: pre; background-color: rgb(39, 39, 39);&quot;&gt;),&amp;nbsp;dp(a&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; text-align: start; white-space: pre; background-color: rgb(39, 39, 39); color: rgb(255, 51, 153);&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: rgb(240, 240, 240); font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; text-align: start; white-space: pre; background-color: rgb(39, 39, 39);&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; text-align: start; white-space: pre; background-color: rgb(39, 39, 39); color: rgb(193, 10, 255);&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: rgb(240, 240, 240); font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; text-align: start; white-space: pre; background-color: rgb(39, 39, 39);&quot;&gt;,&amp;nbsp;b&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; text-align: start; white-space: pre; background-color: rgb(39, 39, 39); color: rgb(255, 51, 153);&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: rgb(240, 240, 240); font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; text-align: start; white-space: pre; background-color: rgb(39, 39, 39);&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; text-align: start; white-space: pre; background-color: rgb(39, 39, 39); color: rgb(193, 10, 255);&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: rgb(240, 240, 240); font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; text-align: start; white-space: pre; background-color: rgb(39, 39, 39);&quot;&gt;)&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; text-align: start; white-space: pre; background-color: rgb(39, 39, 39); color: rgb(255, 51, 153);&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color: rgb(240, 240, 240); font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; text-align: start; white-space: pre; background-color: rgb(39, 39, 39);&quot;&gt;&amp;nbsp;(s1[a]&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; text-align: start; white-space: pre; background-color: rgb(39, 39, 39); color: rgb(255, 51, 153);&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; text-align: start; white-space: pre; background-color: rgb(39, 39, 39); color: rgb(255, 51, 153);&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: rgb(240, 240, 240); font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; text-align: start; white-space: pre; background-color: rgb(39, 39, 39);&quot;&gt;&amp;nbsp;s2[b])&amp;nbsp;});&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;span style=&quot;color: rgb(240, 240, 240); font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; text-align: start; white-space: pre; background-color: rgb(39, 39, 39);&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>Algorithm</category>
      <author>jayharvey</author>
      <guid isPermaLink="true">https://jayharvey.tistory.com/26</guid>
      <comments>https://jayharvey.tistory.com/26#entry26comment</comments>
      <pubDate>Fri, 18 May 2018 15:38:07 +0900</pubDate>
    </item>
    <item>
      <title>백준 2167 2차원 배열의 합</title>
      <link>https://jayharvey.tistory.com/25</link>
      <description>&lt;p style=&quot;text-align: center;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;&amp;lt;DP를 적용하지 않고 for문을 돌려 배열의 합을 구한 경우&amp;gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important; overflow:auto&quot;&gt;&lt;br /&gt;&lt;br /&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin:auto; padding:0; border:none; background-color:#272727; border-radius:4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px; border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0; padding:0; word-break:normal; text-align:right; color:#aaa; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;2&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;3&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;4&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;5&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;6&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;7&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;8&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;9&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;10&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;11&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;12&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;13&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;14&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;15&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;16&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;17&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;18&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;19&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;20&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;21&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;22&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;23&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;24&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;25&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;26&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;27&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;28&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;29&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding:6px 0&quot;&gt;&lt;div style=&quot;margin:0; padding:0; color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;#include&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;cstdio&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;using&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;namespace&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;std&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;arr[&lt;span style=&quot;color:#c10aff&quot;&gt;301&lt;/span&gt;][&lt;span style=&quot;color:#c10aff&quot;&gt;301&lt;/span&gt;];&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;n,&amp;nbsp;m;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;main()&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;scanf&lt;/span&gt;(&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;%d&amp;nbsp;%d&quot;&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;amp;&lt;/span&gt;n,&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;amp;&lt;/span&gt;m);&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;n;&amp;nbsp;i&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;)&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;j&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;;&amp;nbsp;j&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;m;&amp;nbsp;j&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;)&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;scanf&lt;/span&gt;(&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;%d&quot;&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;amp;&lt;/span&gt;arr[i][j]);&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;k;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;scanf&lt;/span&gt;(&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;%d&quot;&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;amp;&lt;/span&gt;k);&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;while&lt;/span&gt;&amp;nbsp;(k&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;)&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;a,&amp;nbsp;b,&amp;nbsp;x,&amp;nbsp;y;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;scanf&lt;/span&gt;(&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;%d&amp;nbsp;%d&amp;nbsp;%d&amp;nbsp;%d&quot;&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;amp;&lt;/span&gt;a,&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;amp;&lt;/span&gt;b,&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;amp;&lt;/span&gt;x,&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;amp;&lt;/span&gt;y);&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;sum&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;a;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;x;&amp;nbsp;i&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;)&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;j&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;b;&amp;nbsp;j&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;y;&amp;nbsp;j&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;)&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;sum&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;arr[i][j];&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;printf&lt;/span&gt;(&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;%d\n&quot;&lt;/span&gt;,&amp;nbsp;sum);&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;return&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;text-align:right; margin-top:-13px; margin-right:5px; font-size:9px; font-style:italic&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: rgb(79, 79, 79);&quot;&gt;Colored by Color Scripter&lt;/a&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align:bottom; padding:0 2px 4px 0&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; background-color: rgb(79, 79, 79); border-radius: 10px; padding: 1px;&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;이렇게 답안을 제출해도 정답처리가 된다.&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;하지만 배열이 커지고 구해야 할 부분합의 갯수가 많아질 경우 시간초과가 날 것이다.&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;그러므로 이 문제를 DP를 이용하여 풀어보면 다음과 같다.&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;&amp;lt;DP를 적용하여 문제를 푼 경우&amp;gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important; overflow:auto&quot;&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin:auto; padding:0; border:none; background-color:#272727; border-radius:4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px; border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0; padding:0; word-break:normal; text-align:right; color:#aaa; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;2&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;3&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;4&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;5&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;6&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;7&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;8&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;9&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;10&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;11&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;12&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;13&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;14&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;15&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;16&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;17&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;18&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;19&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;20&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;21&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;22&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;23&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;24&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding:6px 0&quot;&gt;&lt;div style=&quot;margin:0; padding:0; color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;#include&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;cstdio&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;using&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;namespace&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;std&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;arr[&lt;span style=&quot;color:#c10aff&quot;&gt;301&lt;/span&gt;][&lt;span style=&quot;color:#c10aff&quot;&gt;301&lt;/span&gt;];&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;d[&lt;span style=&quot;color:#c10aff&quot;&gt;301&lt;/span&gt;][&lt;span style=&quot;color:#c10aff&quot;&gt;301&lt;/span&gt;];&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;n,&amp;nbsp;m;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;main()&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;scanf&lt;/span&gt;(&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;%d&amp;nbsp;%d&quot;&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;amp;&lt;/span&gt;n,&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;amp;&lt;/span&gt;m);&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;n;&amp;nbsp;i&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;)&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;j&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;;&amp;nbsp;j&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;m;&amp;nbsp;j&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;)&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;scanf&lt;/span&gt;(&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;%d&quot;&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;amp;&lt;/span&gt;arr[i][j]);&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;d[i][j]&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;arr[i][j]&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&amp;nbsp;d[i&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;][j]&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&amp;nbsp;d[i][j&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;]&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;&amp;nbsp;d[i&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;][j&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;];&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;k;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;scanf&lt;/span&gt;(&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;%d&quot;&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;amp;&lt;/span&gt;k);&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;while&lt;/span&gt;&amp;nbsp;(k&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;)&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;a,&amp;nbsp;b,&amp;nbsp;x,&amp;nbsp;y;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;scanf&lt;/span&gt;(&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;%d&amp;nbsp;%d&amp;nbsp;%d&amp;nbsp;%d&quot;&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;amp;&lt;/span&gt;a,&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;amp;&lt;/span&gt;b,&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;amp;&lt;/span&gt;x,&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;amp;&lt;/span&gt;y);&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;printf&lt;/span&gt;(&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;%d\n&quot;&lt;/span&gt;,&amp;nbsp;d[x][y]&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;&amp;nbsp;d[a&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;][y]&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;&amp;nbsp;d[x][b&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;]&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&amp;nbsp;d[a&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;][b&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;]);&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;return&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;}&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;text-align:right; margin-top:-13px; margin-right:5px; font-size:9px; font-style:italic&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: rgb(79, 79, 79);&quot;&gt;Colored by Color Scripter&lt;/a&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align:bottom; padding:0 2px 4px 0&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; background-color: rgb(79, 79, 79); border-radius: 10px; padding: 1px;&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;걸린 시간을 비교해보면&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;span class=&quot;imageblock&quot; style=&quot;display: inline-block; width: 593px;  height: auto; max-width: 100%;&quot;&gt;&lt;img src=&quot;https://t1.daumcdn.net/cfile/tistory/99435B4C5AFE63642C&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Ft1.daumcdn.net%2Fcfile%2Ftistory%2F99435B4C5AFE63642C&quot; width=&quot;593&quot; height=&quot;227&quot; filename=&quot;2167.png&quot; filemime=&quot;image/jpeg&quot; style=&quot;&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;DP로 풀었을 때 걸린 시간이 20분의 1로 줄었다는 것을 확인할 수 있다. (하지만 메모리를 더 씀..)&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;(중간에 시간초과는 코딩실수....)&lt;/p&gt;</description>
      <category>Algorithm</category>
      <author>jayharvey</author>
      <guid isPermaLink="true">https://jayharvey.tistory.com/25</guid>
      <comments>https://jayharvey.tistory.com/25#entry25comment</comments>
      <pubDate>Fri, 18 May 2018 14:25:13 +0900</pubDate>
    </item>
    <item>
      <title>백준 2163 초콜릿 자르기</title>
      <link>https://jayharvey.tistory.com/24</link>
      <description>&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important; overflow:auto&quot;&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin:auto; padding:0; border:none; background-color:#272727; border-radius:4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px; border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0; padding:0; word-break:normal; text-align:right; color:#aaa; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;2&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;3&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;4&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;5&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;6&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;7&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;8&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;9&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;10&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;11&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;12&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;13&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;14&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;15&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;16&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;17&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;18&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;19&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;20&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;21&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;22&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding:6px 0&quot;&gt;&lt;div style=&quot;margin:0; padding:0; color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#999999&quot;&gt;//&amp;nbsp;12분&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;#include&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;cstdio&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;using&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;namespace&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;std&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;d[&lt;span style=&quot;color:#c10aff&quot;&gt;301&lt;/span&gt;][&lt;span style=&quot;color:#c10aff&quot;&gt;301&lt;/span&gt;];&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;dp(&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;n,&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;m)&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;if&lt;/span&gt;&amp;nbsp;(d[n][m]&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;)&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;return&lt;/span&gt;&amp;nbsp;d[n][m];&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;if&lt;/span&gt;&amp;nbsp;(n&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;amp;&lt;/span&gt;&amp;nbsp;m&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;)&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;return&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;if&lt;/span&gt;&amp;nbsp;(n&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;)&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;return&lt;/span&gt;&amp;nbsp;d[n][m]&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;dp(n,&amp;nbsp;m&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;2&lt;/span&gt;)&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&amp;nbsp;dp(n,&amp;nbsp;m&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;&amp;nbsp;m&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;2&lt;/span&gt;)&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;else&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;return&lt;/span&gt;&amp;nbsp;d[n][m]&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;dp(n&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;2&lt;/span&gt;,&amp;nbsp;m)&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&amp;nbsp;dp(n&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;&amp;nbsp;n&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;/&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;2&lt;/span&gt;,&amp;nbsp;m)&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;main()&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;n,&amp;nbsp;m;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;scanf&lt;/span&gt;(&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;%d&amp;nbsp;%d&quot;&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;amp;&lt;/span&gt;n,&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;amp;&lt;/span&gt;m);&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;printf&lt;/span&gt;(&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;%d\n&quot;&lt;/span&gt;,&amp;nbsp;dp(n,&amp;nbsp;m));&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;return&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;text-align:right; margin-top:-13px; margin-right:5px; font-size:9px; font-style:italic&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: rgb(79, 79, 79);&quot;&gt;Colored by Color Scripter&lt;/a&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align:bottom; padding:0 2px 4px 0&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; background-color: rgb(79, 79, 79); border-radius: 10px; padding: 1px;&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p style=&quot;text-align: center; clear: none; float: none;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;다이나믹 프로그래밍 문제&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;이 문제는 정말 쉽다. 단순하게 n*m-1을 출력해도 정답 처리가 된다.&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;하지만 dp문제를 풀기로 했으므로 dp다운 접근을 하여 코드를 짰다.&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>Algorithm</category>
      <author>jayharvey</author>
      <guid isPermaLink="true">https://jayharvey.tistory.com/24</guid>
      <comments>https://jayharvey.tistory.com/24#entry24comment</comments>
      <pubDate>Fri, 18 May 2018 13:48:36 +0900</pubDate>
    </item>
    <item>
      <title>백준 1010 다리 놓기</title>
      <link>https://jayharvey.tistory.com/23</link>
      <description>&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important; overflow:auto&quot;&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin:auto; padding:0; border:none; background-color:#272727; border-radius:4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px; border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0; padding:0; word-break:normal; text-align:right; color:#aaa; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;2&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;3&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;4&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;5&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;6&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;7&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;8&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;9&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;10&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;11&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;12&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;13&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;14&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;15&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;16&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;17&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;18&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;19&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;20&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;21&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;22&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;23&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;24&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;25&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;26&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding:6px 0&quot;&gt;&lt;div style=&quot;margin:0; padding:0; color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;#include&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;cstdio&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;using&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;namespace&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;std&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;d[&lt;span style=&quot;color:#c10aff&quot;&gt;31&lt;/span&gt;][&lt;span style=&quot;color:#c10aff&quot;&gt;31&lt;/span&gt;];&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#999999&quot;&gt;//&amp;nbsp;nCr&amp;nbsp;=&amp;nbsp;n-1Cr&amp;nbsp;+&amp;nbsp;n-1Cr-1&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;com(&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;n,&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;r)&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;if&lt;/span&gt;&amp;nbsp;(d[n][r]&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;)&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;return&lt;/span&gt;&amp;nbsp;d[n][r];&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;if&lt;/span&gt;&amp;nbsp;(n&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;r&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;|&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;|&lt;/span&gt;&amp;nbsp;r&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;)&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;return&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;else&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;if&lt;/span&gt;&amp;nbsp;(n&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&amp;nbsp;r)&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;return&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;else&lt;/span&gt;&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;return&lt;/span&gt;&amp;nbsp;d[n][r]&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;com(n&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;,&amp;nbsp;r)&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&amp;nbsp;com(n&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;,&amp;nbsp;r&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;);&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;main()&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;t;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;scanf&lt;/span&gt;(&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;%d&quot;&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;amp;&lt;/span&gt;t);&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;while&lt;/span&gt;&amp;nbsp;(t&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;)&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;n,&amp;nbsp;m;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;scanf&lt;/span&gt;(&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;%d&amp;nbsp;%d&quot;&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;amp;&lt;/span&gt;n,&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;amp;&lt;/span&gt;m);&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;printf&lt;/span&gt;(&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;%d\n&quot;&lt;/span&gt;,&amp;nbsp;com(m,&amp;nbsp;n));&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;return&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;text-align:right; margin-top:-13px; margin-right:5px; font-size:9px; font-style:italic&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: rgb(79, 79, 79);&quot;&gt;Colored by Color Scripter&lt;/a&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align:bottom; padding:0 2px 4px 0&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; background-color: rgb(79, 79, 79); border-radius: 10px; padding: 1px;&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;6번 줄의&amp;nbsp;&lt;span style=&quot;background-color: rgb(39, 39, 39); color: rgb(153, 153, 153); font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; white-space: pre;&quot;&gt;//&amp;nbsp;nCr&amp;nbsp;=&amp;nbsp;n-1Cr&amp;nbsp;+&amp;nbsp;n-1Cr-1&lt;/span&gt;&amp;nbsp;이것을 이용하는 것이 핵심이다.&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;일반적인 조합의 성질인&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;img class=&quot;txc-formula&quot; src=&quot;https://t1.daumcdn.net/cfile/tistory/9971434A5AFE3B5C06&quot; historydata=&quot;%3Cflashrichtext%20version%3D%221%22%3E%0A%20%20%3Ctextformat%20font%3D%22Dotum%22%20size%3D%2216%22%20color%3D%222236962%22%20bold%3D%22false%22%20italic%3D%22false%22%20underline%3D%22false%22%20url%3D%22%22%20target%3D%22transparent%22%20align%3D%22left%22%20leftMargin%3D%2225%22%20rightMargin%3D%2225%22%20indent%3D%220%22%20leading%3D%220%22%20blockIndent%3D%220%22%20kerning%3D%22true%22%20letterSpacing%3D%220%22%20display%3D%22block%22%3E%28nCr%5Cquad%20%3D%5Cquad%20%5Cfrac%20%7B%20n%21%20%7D%7B%20%28n-r%29%21r%21%20%7D%20%29%3C/textformat%3E%0A%3C/flashrichtext%3E%2C%0A14%2C%0A0xFFFFFF&quot; width=&quot;166&quot; height=&quot;58&quot;&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;이 공식을 이용하여 코드를&amp;nbsp;짜는 경우 long long int 자료형으로도 29! 을 담을 수 없으므로 불가능한 방법이다.&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;DP로 풀기로 했으니 그 성질을 이용하여 위와 같이 풀었다.&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;22번 줄의&amp;nbsp;&lt;span style=&quot;font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; white-space: pre; background-color: rgb(39, 39, 39); color: rgb(75, 230, 250);&quot;&gt;printf&lt;/span&gt;&lt;span style=&quot;color: rgb(240, 240, 240); font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; white-space: pre; background-color: rgb(39, 39, 39);&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; white-space: pre; background-color: rgb(39, 39, 39); color: rgb(255, 213, 0);&quot;&gt;&quot;%d\n&quot;&lt;/span&gt;&lt;span style=&quot;color: rgb(240, 240, 240); font-family: Consolas, &amp;quot;Liberation Mono&amp;quot;, Menlo, Courier, monospace; white-space: pre; background-color: rgb(39, 39, 39);&quot;&gt;,&amp;nbsp;com(m,&amp;nbsp;n));&lt;/span&gt;&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;com을 호출할 때 인자를 바꿔서 넣어주어야 하는 것을 잊지말 것.&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>Algorithm</category>
      <author>jayharvey</author>
      <guid isPermaLink="true">https://jayharvey.tistory.com/23</guid>
      <comments>https://jayharvey.tistory.com/23#entry23comment</comments>
      <pubDate>Fri, 18 May 2018 11:35:07 +0900</pubDate>
    </item>
    <item>
      <title>백준 1003 피보나치 함수</title>
      <link>https://jayharvey.tistory.com/22</link>
      <description>&lt;p style=&quot;text-align: center;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;&amp;lt;Bottom-Up&amp;gt; 방식&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;n은 최대 40까지이므로 for문을 돌려 40까지의 답을 구해 놓은 후 풀었다.&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;/p&gt;&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important; overflow:auto&quot;&gt;&lt;br /&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin:auto; padding:0; border:none; background-color:#272727; border-radius:4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px; border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0; padding:0; word-break:normal; text-align:right; color:#aaa; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;2&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;3&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;4&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;5&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;6&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;7&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;8&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;9&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;10&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;11&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;12&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;13&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;14&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;15&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;16&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;17&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;18&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;19&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;20&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;21&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;22&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;23&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding:6px 0&quot;&gt;&lt;div style=&quot;margin:0; padding:0; color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;#include&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;cstdio&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;using&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;namespace&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;std&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;d[&lt;span style=&quot;color:#c10aff&quot;&gt;41&lt;/span&gt;][&lt;span style=&quot;color:#c10aff&quot;&gt;2&lt;/span&gt;];&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;main()&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;d[&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;]&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;d[&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;][&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;]&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;d[&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;]&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;d[&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;][&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;]&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;for&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;2&lt;/span&gt;;&amp;nbsp;i&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;40&lt;/span&gt;;&amp;nbsp;i&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;)&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;d[i][&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;]&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;d[i&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;][&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;]&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&amp;nbsp;d[i&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;2&lt;/span&gt;][&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;];&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;d[i][&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;]&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;d[i&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;][&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;]&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&amp;nbsp;d[i&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;2&lt;/span&gt;][&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;];&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;t;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;scanf&lt;/span&gt;(&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;%d&quot;&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;amp;&lt;/span&gt;t);&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;while&lt;/span&gt;&amp;nbsp;(t&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;)&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;n;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;scanf&lt;/span&gt;(&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;%d&quot;&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;amp;&lt;/span&gt;n);&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;printf&lt;/span&gt;(&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;%d&amp;nbsp;%d\n&quot;&lt;/span&gt;,&amp;nbsp;d[n][&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;],&amp;nbsp;d[n][&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;]);&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;return&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;text-align:right; margin-top:-13px; margin-right:5px; font-size:9px; font-style:italic&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: rgb(79, 79, 79);&quot;&gt;Colored by Color Scripter&lt;/a&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align:bottom; padding:0 2px 4px 0&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; background-color: rgb(79, 79, 79); border-radius: 10px; padding: 1px;&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;&amp;lt;Top-Down 방식&amp;gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;규칙을 잘 살펴보면 n일 때의 0의 갯수는 n-1일 때의 1의 갯수와 같다.&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;colorscripter-code&quot; style=&quot;color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important; overflow:auto&quot;&gt;&lt;table class=&quot;colorscripter-code-table&quot; style=&quot;margin:auto; padding:0; border:none; background-color:#272727; border-radius:4px;&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td style=&quot;padding:6px; border-right:2px solid #4f4f4f&quot;&gt;&lt;div style=&quot;margin:0; padding:0; word-break:normal; text-align:right; color:#aaa; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;line-height:130%&quot;&gt;1&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;2&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;3&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;4&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;5&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;6&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;7&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;8&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;9&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;10&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;11&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;12&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;13&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;14&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;15&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;16&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;17&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;18&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;19&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;20&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;21&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;22&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;23&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;24&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;25&lt;/div&gt;&lt;div style=&quot;line-height:130%&quot;&gt;26&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;padding:6px 0&quot;&gt;&lt;div style=&quot;margin:0; padding:0; color:#f0f0f0; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; line-height:130%&quot;&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#0086b3&quot;&gt;#include&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;lt;&lt;/span&gt;cstdio&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;using&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;namespace&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;std&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;d[&lt;span style=&quot;color:#c10aff&quot;&gt;41&lt;/span&gt;];&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;fibonacci(&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;n)&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;if&lt;/span&gt;&amp;nbsp;(d[n]&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;)&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;return&lt;/span&gt;&amp;nbsp;d[n];&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;if&lt;/span&gt;&amp;nbsp;(n&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;)&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;return&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;else&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;if&lt;/span&gt;&amp;nbsp;(n&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;)&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;return&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;else&lt;/span&gt;&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;return&lt;/span&gt;&amp;nbsp;d[n]&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;fibonacci(n&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;)&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;+&lt;/span&gt;&amp;nbsp;fibonacci(n&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;2&lt;/span&gt;);&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;main()&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;t;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;scanf&lt;/span&gt;(&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;%d&quot;&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;amp;&lt;/span&gt;t);&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;while&lt;/span&gt;&amp;nbsp;(t&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;)&amp;nbsp;{&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;int&lt;/span&gt;&amp;nbsp;n;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;scanf&lt;/span&gt;(&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;%d&quot;&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;&amp;amp;&lt;/span&gt;n);&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;if&lt;/span&gt;&amp;nbsp;(n&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:#ff3399&quot;&gt;=&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;)&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;printf&lt;/span&gt;(&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;1&amp;nbsp;0\n&quot;&lt;/span&gt;);&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;else&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#4be6fa&quot;&gt;printf&lt;/span&gt;(&lt;span style=&quot;color:#ffd500&quot;&gt;&quot;%d&amp;nbsp;%d\n&quot;&lt;/span&gt;,&amp;nbsp;fibonacci(n&lt;span style=&quot;color:#ff3399&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color:#c10aff&quot;&gt;1&lt;/span&gt;),&amp;nbsp;fibonacci(n));&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color:#ff3399&quot;&gt;return&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color:#c10aff&quot;&gt;0&lt;/span&gt;;&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;}&lt;/div&gt;&lt;div style=&quot;padding:0 6px; white-space:pre; line-height:130%&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;text-align:right; margin-top:-13px; margin-right:5px; font-size:9px; font-style:italic&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: rgb(79, 79, 79);&quot;&gt;Colored by Color Scripter&lt;/a&gt;&lt;/div&gt;&lt;/td&gt;&lt;td style=&quot;vertical-align:bottom; padding:0 2px 4px 0&quot;&gt;&lt;a href=&quot;http://colorscripter.com/info#e&quot; target=&quot;_blank&quot; style=&quot;color: white;&quot;&gt;&lt;span style=&quot;font-size: 9px; word-break: normal; background-color: rgb(79, 79, 79); border-radius: 10px; padding: 1px;&quot;&gt;cs&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>Algorithm</category>
      <author>jayharvey</author>
      <guid isPermaLink="true">https://jayharvey.tistory.com/22</guid>
      <comments>https://jayharvey.tistory.com/22#entry22comment</comments>
      <pubDate>Fri, 18 May 2018 10:47:59 +0900</pubDate>
    </item>
  </channel>
</rss>