<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>수학 Archives - 어제와 내일의 나 그 사이의 이야기</title>
	<atom:link href="https://lycos7560.com/tag/%ec%88%98%ed%95%99/feed/" rel="self" type="application/rss+xml" />
	<link></link>
	<description>생각의 흐름을 타고 다니며 만드는 블로그</description>
	<lastBuildDate>Mon, 10 Mar 2025 09:42:44 +0000</lastBuildDate>
	<language>ko-KR</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://lycos7560.com/wp-content/uploads/2022/11/cropped-cropped-cropped-log-1-150x150-1-80x80.png</url>
	<title>수학 Archives - 어제와 내일의 나 그 사이의 이야기</title>
	<link></link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>백준 28702번 (FizzBuzz, C++) [BAEKJOON]</title>
		<link>https://lycos7560.com/cpp/%eb%b0%b1%ec%a4%80-28702%eb%b2%88-fizzbuzz-c-baekjoon/39926/</link>
					<comments>https://lycos7560.com/cpp/%eb%b0%b1%ec%a4%80-28702%eb%b2%88-fizzbuzz-c-baekjoon/39926/#respond</comments>
		
		<dc:creator><![CDATA[lycos7560]]></dc:creator>
		<pubDate>Tue, 24 Dec 2024 09:35:33 +0000</pubDate>
				<category><![CDATA[BaekjoonOnlineJudge]]></category>
		<category><![CDATA[C++/CPP]]></category>
		<category><![CDATA[28702]]></category>
		<category><![CDATA[28702번]]></category>
		<category><![CDATA[Baekjoon]]></category>
		<category><![CDATA[Buzz]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[cpp]]></category>
		<category><![CDATA[Fizz]]></category>
		<category><![CDATA[FizzBuzz]]></category>
		<category><![CDATA[study]]></category>
		<category><![CDATA[공부]]></category>
		<category><![CDATA[기초]]></category>
		<category><![CDATA[문자열]]></category>
		<category><![CDATA[백준]]></category>
		<category><![CDATA[백준 28702번]]></category>
		<category><![CDATA[수학]]></category>
		<category><![CDATA[알고리즘]]></category>
		<category><![CDATA[코딩테스트]]></category>
		<category><![CDATA[코테]]></category>
		<guid isPermaLink="false">https://lycos7560.com/?p=39926</guid>

					<description><![CDATA[<p>FizzBuzz https://www.acmicpc.net/problem/28702 시간 제한 메모리 제한 제출 정답 맞힌 사람 정답 비율 0.5 초 1024 MB 13102 8022 7260 61.593% 문제 FizzBuzz 문제는 i=1,2,⋯ 에 대해 다음 규칙에 따라 문자열을 한 줄에 하나씩 출력하는 문제입니다. FizzBuzz 문제에서 연속으로 출력된 세 개의 문자열이 주어집니다. 이때, 이 세 문자열 다음에 올 문자열은 무엇일까요? 입력 FizzBuzz 문제에서 연속으로 출력된 세 [&#8230;]</p>
<p>The post <a href="https://lycos7560.com/cpp/%eb%b0%b1%ec%a4%80-28702%eb%b2%88-fizzbuzz-c-baekjoon/39926/">백준 28702번 (FizzBuzz, C++) [BAEKJOON]</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading">FizzBuzz <img decoding="async" width="30" height="38" class="wp-image-37923" style="width: 30px;" src="https://lycos7560.com/wp-content/uploads/2024/03/Bronze_1.jpg" alt="" srcset="https://lycos7560.com/wp-content/uploads/2024/03/Bronze_1.jpg 1250w, https://lycos7560.com/wp-content/uploads/2024/03/Bronze_1-234x300.jpg 234w, https://lycos7560.com/wp-content/uploads/2024/03/Bronze_1-768x983.jpg 768w, https://lycos7560.com/wp-content/uploads/2024/03/Bronze_1-1200x1536.jpg 1200w" sizes="(max-width: 30px) 100vw, 30px" /></h2>



<p><a href="https://www.acmicpc.net/problem/28702" target="_blank" rel="noreferrer noopener">https://www.acmicpc.net/problem/28702</a></p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><th class="has-text-align-left" data-align="left">시간 제한</th><th class="has-text-align-left" data-align="left">메모리 제한</th><th class="has-text-align-left" data-align="left">제출</th><th class="has-text-align-left" data-align="left">정답</th><th class="has-text-align-left" data-align="left">맞힌 사람</th><th class="has-text-align-left" data-align="left">정답 비율</th></tr></thead><tbody><tr><td class="has-text-align-left" data-align="left">0.5 초</td><td class="has-text-align-left" data-align="left">1024 MB</td><td class="has-text-align-left" data-align="left">13102</td><td class="has-text-align-left" data-align="left">8022</td><td class="has-text-align-left" data-align="left">7260</td><td class="has-text-align-left" data-align="left">61.593%</td></tr></tbody></table></figure>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading">문제</h3>



<p>FizzBuzz 문제는 i=1,2,⋯ 에 대해 다음 규칙에 따라 문자열을 한 줄에 하나씩 출력하는 문제입니다.</p>



<ul class="wp-block-list">
<li> i가 3의 배수이면서 5의 배수이면 “<code>FizzBuzz</code>”를 출력합니다.</li>



<li> i가 3의 배수이지만 5의 배수가 아니면 “<code>Fizz</code>”를 출력합니다.</li>



<li> i가 3의 배수가 아니지만 5의 배수이면 “<code>Buzz</code>”를 출력합니다.</li>



<li> i가 3의 배수도 아니고 5의 배수도 아닌 경우 i를 그대로 출력합니다.</li>
</ul>



<p>FizzBuzz 문제에서 연속으로 출력된 세 개의 문자열이 주어집니다. </p>



<p>이때, 이 세 문자열 다음에 올 문자열은 무엇일까요?</p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading">입력</h3>



<p>FizzBuzz 문제에서 연속으로 출력된 세 개의 문자열이 한 줄에 하나씩 주어집니다. </p>



<p>각 문자열의 길이는 8 이하입니다. 입력이 항상 FizzBuzz 문제에서 연속으로 출력된 세 개의 문자열에 대응됨이 보장됩니다.</p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading">출력</h3>



<p>연속으로 출력된 세 개의 문자열 다음에 올 문자열을 출력하세요. </p>



<p>여러 문자열이 올 수 있는 경우, 아무거나 하나 출력하세요.</p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading">예제 입력 1</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">Fizz
Buzz
11</pre>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading">예제 출력 1</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">Fizz</pre>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading">예제 입력 2</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">980803
980804
FizzBuzz</pre>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading">예제 출력 2</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">980806</pre>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading">힌트</h3>



<p>FizzBuzz 문제의 i = 1 ,⋯, 20에 대한 출력은 다음과 같습니다.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">1
2
Fizz
4
Buzz
Fizz
7
8
Fizz
Buzz
11
Fizz
13
14
FizzBuzz
16
17
Fizz
19
Buzz</pre>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading">출처</h3>



<p><a href="https://www.acmicpc.net/category/45" target="_blank" rel="noreferrer noopener">Contest</a> > <a href="https://www.acmicpc.net/category/859" target="_blank" rel="noreferrer noopener">solved.ac</a> > <a href="https://www.acmicpc.net/category/detail/3707" target="_blank" rel="noreferrer noopener">solved.ac Grand Arena #2</a> B번</p>



<ul class="wp-block-list">
<li>문제를 검수한 사람: <a href="https://www.acmicpc.net/user/ai4youej" target="_blank" rel="noreferrer noopener">ai4youej</a>, <a href="https://www.acmicpc.net/user/bnb2011" target="_blank" rel="noreferrer noopener">bnb2011</a>, <a href="https://www.acmicpc.net/user/chansol" target="_blank" rel="noreferrer noopener">chansol</a>, <a href="https://www.acmicpc.net/user/cologne" target="_blank" rel="noreferrer noopener">cologne</a>, <a href="https://www.acmicpc.net/user/cozyyg" target="_blank" rel="noreferrer noopener">cozyyg</a>, <a href="https://www.acmicpc.net/user/gs18115" target="_blank" rel="noreferrer noopener">gs18115</a>, <a href="https://www.acmicpc.net/user/havana723" target="_blank" rel="noreferrer noopener">havana723</a>, <a href="https://www.acmicpc.net/user/jh05013" target="_blank" rel="noreferrer noopener">jh05013</a>, <a href="https://www.acmicpc.net/user/moonrabbit2" target="_blank" rel="noreferrer noopener">moonrabbit2</a>, <a href="https://www.acmicpc.net/user/pichulia" target="_blank" rel="noreferrer noopener">pichulia</a>, <a href="https://www.acmicpc.net/user/shiftpsh" target="_blank" rel="noreferrer noopener">shiftpsh</a></li>



<li>문제를 만든 사람: <a href="https://www.acmicpc.net/user/cologne">cologne</a>, <a href="https://www.acmicpc.net/user/solvedac">solvedac</a></li>
</ul>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading">알고리즘 분류</h3>



<ul class="wp-block-list">
<li><a href="https://www.acmicpc.net/problem/tag/124" target="_blank" rel="noreferrer noopener">수학</a></li>



<li><a href="https://www.acmicpc.net/problem/tag/158" target="_blank" rel="noreferrer noopener">문자열</a></li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity is-style-wide" style="margin-top:var(--wp--preset--spacing--80);margin-bottom:var(--wp--preset--spacing--80)"/>



<h3 class="wp-block-heading">통과된 코드</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="cpp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#include &lt;iostream>
#include &lt;string>

using namespace std;

string Input[3];

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    for (int i = 0; i &lt; 3; i++)
        cin >> Input[i];

    for (int i = 0; i &lt; 3; i++) {
        if (Input[i][0] == 'F' || Input[i][0] == 'B')
            continue;

        int Num = stoi(Input[i]) + 3 - i;
        if (Num % 15 == 0) cout &lt;&lt; "FizzBuzz";
        else if (Num % 5 == 0) cout &lt;&lt; "Buzz";
        else if (Num % 3 == 0) cout &lt;&lt; "Fizz";
        else cout &lt;&lt; Num;
        return 0;
    }

    cout &lt;&lt; "FizzBuzz";

    return 0;
}
</pre>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-image size-full"><img fetchpriority="high" decoding="async" width="960" height="76" src="https://lycos7560.com/wp-content/uploads/2025/03/image-11.png" alt="" class="wp-image-39927" srcset="https://lycos7560.com/wp-content/uploads/2025/03/image-11.png 960w, https://lycos7560.com/wp-content/uploads/2025/03/image-11-300x24.png 300w, https://lycos7560.com/wp-content/uploads/2025/03/image-11-768x61.png 768w" sizes="(max-width: 960px) 100vw, 960px" /></figure>
<p>The post <a href="https://lycos7560.com/cpp/%eb%b0%b1%ec%a4%80-28702%eb%b2%88-fizzbuzz-c-baekjoon/39926/">백준 28702번 (FizzBuzz, C++) [BAEKJOON]</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://lycos7560.com/cpp/%eb%b0%b1%ec%a4%80-28702%eb%b2%88-fizzbuzz-c-baekjoon/39926/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>백준 13458번 (시험 감독, C++) [BAEKJOON]</title>
		<link>https://lycos7560.com/cpp/%eb%b0%b1%ec%a4%80-13458%eb%b2%88-%ec%8b%9c%ed%97%98-%ea%b0%90%eb%8f%85-c-baekjoon/38391/</link>
					<comments>https://lycos7560.com/cpp/%eb%b0%b1%ec%a4%80-13458%eb%b2%88-%ec%8b%9c%ed%97%98-%ea%b0%90%eb%8f%85-c-baekjoon/38391/#respond</comments>
		
		<dc:creator><![CDATA[lycos7560]]></dc:creator>
		<pubDate>Thu, 17 Oct 2024 11:53:58 +0000</pubDate>
				<category><![CDATA[BaekjoonOnlineJudge]]></category>
		<category><![CDATA[C++/CPP]]></category>
		<category><![CDATA[13458]]></category>
		<category><![CDATA[13458번]]></category>
		<category><![CDATA[Baekjoon]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[cpp]]></category>
		<category><![CDATA[study]]></category>
		<category><![CDATA[공부]]></category>
		<category><![CDATA[기초]]></category>
		<category><![CDATA[백준]]></category>
		<category><![CDATA[백준 13458]]></category>
		<category><![CDATA[백준 13458번]]></category>
		<category><![CDATA[사칙연산]]></category>
		<category><![CDATA[수학]]></category>
		<category><![CDATA[시험 감독]]></category>
		<category><![CDATA[시험감독]]></category>
		<category><![CDATA[알고리즘]]></category>
		<category><![CDATA[코딩테스트]]></category>
		<category><![CDATA[코테]]></category>
		<guid isPermaLink="false">https://lycos7560.com/?p=38391</guid>

					<description><![CDATA[<p>시험 감독 https://www.acmicpc.net/problem/13458 시간 제한 메모리 제한 제출 정답 맞힌 사람 정답 비율 2 초 512 MB 99556 31008 23090 29.650% 문제 총 N개의 시험장이 있고, 각각의 시험장마다 응시자들이 있다. i번 시험장에 있는 응시자의 수는 Ai명이다. 감독관은 총감독관과 부감독관으로 두 종류가 있다. 총감독관은 한 시험장에서 감시할 수 있는 응시자의 수가 B명이고, 부감독관은 한 시험장에서 감시할 [&#8230;]</p>
<p>The post <a href="https://lycos7560.com/cpp/%eb%b0%b1%ec%a4%80-13458%eb%b2%88-%ec%8b%9c%ed%97%98-%ea%b0%90%eb%8f%85-c-baekjoon/38391/">백준 13458번 (시험 감독, C++) [BAEKJOON]</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<h1 class="wp-block-heading">시험 감독 <img decoding="async" width="35" height="45" class="wp-image-37920" style="width: 35px;" src="https://lycos7560.com/wp-content/uploads/2024/03/Bronze_2.jpg" alt="" srcset="https://lycos7560.com/wp-content/uploads/2024/03/Bronze_2.jpg 1250w, https://lycos7560.com/wp-content/uploads/2024/03/Bronze_2-234x300.jpg 234w, https://lycos7560.com/wp-content/uploads/2024/03/Bronze_2-768x983.jpg 768w, https://lycos7560.com/wp-content/uploads/2024/03/Bronze_2-1200x1536.jpg 1200w" sizes="(max-width: 35px) 100vw, 35px" /></h1>



<p><a href="https://www.acmicpc.net/problem/13458" target="_blank" rel="noreferrer noopener">https://www.acmicpc.net/problem/13458</a></p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><th class="has-text-align-left" data-align="left">시간 제한</th><th class="has-text-align-left" data-align="left">메모리 제한</th><th class="has-text-align-left" data-align="left">제출</th><th class="has-text-align-left" data-align="left">정답</th><th class="has-text-align-left" data-align="left">맞힌 사람</th><th class="has-text-align-left" data-align="left">정답 비율</th></tr></thead><tbody><tr><td class="has-text-align-left" data-align="left">2 초</td><td class="has-text-align-left" data-align="left">512 MB</td><td class="has-text-align-left" data-align="left">99556</td><td class="has-text-align-left" data-align="left">31008</td><td class="has-text-align-left" data-align="left">23090</td><td class="has-text-align-left" data-align="left">29.650%</td></tr></tbody></table></figure>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">문제</h2>



<p>총 N개의 시험장이 있고, 각각의 시험장마다 응시자들이 있다.</p>



<p>i번 시험장에 있는 응시자의 수는 A<sub>i</sub>명이다.</p>



<p>감독관은 총감독관과 부감독관으로 두 종류가 있다. </p>



<p>총감독관은 한 시험장에서 감시할 수 있는 응시자의 수가 B명이고, 부감독관은 한 시험장에서 감시할 수 있는 응시자의 수가 C명이다.</p>



<p>각각의 시험장에 총감독관은 오직 1명만 있어야 하고, 부감독관은 여러 명 있어도 된다.</p>



<p>각 시험장마다 응시생들을 모두 감시해야 한다. </p>



<p>이때, 필요한 감독관 수의 최솟값을 구하는 프로그램을 작성하시오.</p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">입력</h2>



<p>첫째 줄에 시험장의 개수 N(1 ≤ N ≤ 1,000,000)이 주어진다.</p>



<p>둘째 줄에는 각 시험장에 있는 응시자의 수 A<sub>i</sub>&nbsp;(1 ≤ A<sub>i</sub>&nbsp;≤ 1,000,000)가 주어진다.</p>



<p>셋째 줄에는 B와 C가 주어진다. (1 ≤ B, C ≤ 1,000,000)</p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">출력</h2>



<p>각 시험장마다 응시생을 모두 감독하기 위해 필요한 감독관의 최소 수를 출력한다.</p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading">예제 입/출력 1</h3>



<div class="wp-block-uagb-container uagb-block-ecb9f492 alignfull uagb-is-root-container"><div class="uagb-container-inner-blocks-wrap">
<div class="wp-block-uagb-container uagb-block-5a2a4110">
<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">1
1
1 1</pre>
</div>



<div class="wp-block-uagb-container uagb-block-99e5d95d">
<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">1</pre>
</div>
</div></div>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading">예제 입/출력 2</h3>



<div class="wp-block-uagb-container uagb-block-1a4486a4 alignfull uagb-is-root-container"><div class="uagb-container-inner-blocks-wrap">
<div class="wp-block-uagb-container uagb-block-edc25381">
<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">3
3 4 5
2 2</pre>
</div>



<div class="wp-block-uagb-container uagb-block-7c5a70a3">
<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">7</pre>
</div>
</div></div>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading">예제 입/출력 3</h3>



<div class="wp-block-uagb-container uagb-block-71ca8357 alignfull uagb-is-root-container"><div class="uagb-container-inner-blocks-wrap">
<div class="wp-block-uagb-container uagb-block-b1bd4748">
<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">5
1000000 1000000 1000000 1000000 1000000
5 7</pre>
</div>



<div class="wp-block-uagb-container uagb-block-dec598d8">
<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">714290</pre>
</div>
</div></div>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading">예제 입/출력 4</h3>



<div class="wp-block-uagb-container uagb-block-bda1c3c3 alignfull uagb-is-root-container"><div class="uagb-container-inner-blocks-wrap">
<div class="wp-block-uagb-container uagb-block-8f098227">
<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">5
10 9 10 9 10
7 20</pre>
</div>



<div class="wp-block-uagb-container uagb-block-7fe3ea99">
<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">13</pre>
</div>
</div></div>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading">추가 예제 입/출력 5</h3>



<div class="wp-block-uagb-container uagb-block-4452252d alignfull uagb-is-root-container"><div class="uagb-container-inner-blocks-wrap">
<div class="wp-block-uagb-container uagb-block-ec7b5546">
<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">2
1000000 1
999999 1</pre>
</div>



<div class="wp-block-uagb-container uagb-block-ef7f641b">
<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">3</pre>
</div>
</div></div>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading">추가 예제 입/출력 6</h3>



<div class="wp-block-uagb-container uagb-block-fc839852 alignfull uagb-is-root-container"><div class="uagb-container-inner-blocks-wrap">
<div class="wp-block-uagb-container uagb-block-446d62a4">
<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">1
1
6 2</pre>
</div>



<div class="wp-block-uagb-container uagb-block-586f7842">
<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">1</pre>
</div>
</div></div>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading">추가 예제 입/출력 7</h3>



<div class="wp-block-uagb-container uagb-block-fbf0851b alignfull uagb-is-root-container"><div class="uagb-container-inner-blocks-wrap">
<div class="wp-block-uagb-container uagb-block-c02c2462">
<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">3
3 4 5
3 1</pre>
</div>



<div class="wp-block-uagb-container uagb-block-f9b200a3">
<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">6</pre>
</div>
</div></div>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading">추가 예제 입/출력 8</h3>



<div class="wp-block-uagb-container uagb-block-d1c29276 alignfull uagb-is-root-container"><div class="uagb-container-inner-blocks-wrap">
<div class="wp-block-uagb-container uagb-block-1b2f98bb">
<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">5
10 9 10 10 10
5 1</pre>
</div>



<div class="wp-block-uagb-container uagb-block-4784af00">
<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">29</pre>
</div>
</div></div>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">출처</h2>



<ul class="wp-block-list">
<li>문제를 만든 사람: <a href="https://www.acmicpc.net/user/baekjoon" target="_blank" rel="noreferrer noopener">baekjoon</a></li>



<li>문제의 오타를 찾은 사람: <a href="https://www.acmicpc.net/user/citizen" target="_blank" rel="noreferrer noopener">citizen</a>, <a href="https://www.acmicpc.net/user/corea" target="_blank" rel="noreferrer noopener">corea</a>, <a href="https://www.acmicpc.net/user/jhpark1109" target="_blank" rel="noreferrer noopener">jhpark1109</a></li>



<li>데이터를 추가한 사람: <a href="https://www.acmicpc.net/user/doju" target="_blank" rel="noreferrer noopener">doju</a></li>
</ul>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">알고리즘 분류</h2>



<ul class="wp-block-list">
<li><a href="https://www.acmicpc.net/problem/tag/124" target="_blank" rel="noreferrer noopener">수학</a></li>



<li><a href="https://www.acmicpc.net/problem/tag/121" target="_blank" rel="noreferrer noopener">사칙연산</a></li>
</ul>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">통과된 코드</h2>



<p>합계는 int의 범위를 넘어간다는 것과 계산중 -일 경우를 예외처리가 필요</p>



<pre class="EnlighterJSRAW" data-enlighter-language="cpp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#include &lt;iostream>
using namespace std;

// 총 감시해야 할 시험장의 수 N, 각 시험장의 감독관 수 A, 부감독관 수 B, C를 저장할 변수
int N, A, B, C;

// 각 시험장의 응시자 수를 저장할 배열
int Room[1000000] = { 0 };

int main() {
    ios_base::sync_with_stdio(0); // C++의 표준 스트림의 동기화를 비활성화
    cin.tie(0); // 입력과 출력이 묶이지 않도록 함
    cout.tie(0); // 출력 속도를 높임

    cin >> N; // 총 시험장의 수 입력 받기
    for (int i = 0; i &lt; N; i++)
        cin >> Room[i]; // 각 시험장의 응시자 수 입력 받기

    cin >> B >> C; // 총감독관 B와 부감독관 C의 감시 가능한 응시자 수 입력 받기

    long long int Sum = 0; // 필요한 감독관의 총 수를 저장할 변수
    for (int i = 0; i &lt; N; i++) {
        int Temp = Room[i] - B; // 각 시험장의 응시자 수에서 총감독관이 감시 가능한 응시자 수를 뺌
        Sum += 1; // 총감독관은 무조건 한 명 필요
        if (Temp &lt; 0)
            continue; // 총감독관이 감시 가능한 수보다 적으면 부감독관 필요 없음
        Sum += Temp / C; // 남은 응시자 수를 부감독관이 감시 가능한 수로 나눠서 추가
        if (Temp % C > 0)
            Sum++; // 나머지가 있으면 추가로 한 명의 부감독관이 필요
    }

    cout &lt;&lt; Sum; // 필요한 감독관의 총 수 출력
    return 0;
}
</pre>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-image size-full"><img decoding="async" width="1304" height="133" src="https://lycos7560.com/wp-content/uploads/2024/10/image-15.png" alt="" class="wp-image-38392" srcset="https://lycos7560.com/wp-content/uploads/2024/10/image-15.png 1304w, https://lycos7560.com/wp-content/uploads/2024/10/image-15-300x31.png 300w, https://lycos7560.com/wp-content/uploads/2024/10/image-15-768x78.png 768w" sizes="(max-width: 1304px) 100vw, 1304px" /></figure>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<p></p>
<p>The post <a href="https://lycos7560.com/cpp/%eb%b0%b1%ec%a4%80-13458%eb%b2%88-%ec%8b%9c%ed%97%98-%ea%b0%90%eb%8f%85-c-baekjoon/38391/">백준 13458번 (시험 감독, C++) [BAEKJOON]</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://lycos7560.com/cpp/%eb%b0%b1%ec%a4%80-13458%eb%b2%88-%ec%8b%9c%ed%97%98-%ea%b0%90%eb%8f%85-c-baekjoon/38391/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>백준 30802번 (웰컴 키트, C++) [BAEKJOON]</title>
		<link>https://lycos7560.com/cpp/%eb%b0%b1%ec%a4%80-30802%eb%b2%88-%ec%9b%b0%ec%bb%b4-%ed%82%a4%ed%8a%b8-c-baekjoon/39921/</link>
					<comments>https://lycos7560.com/cpp/%eb%b0%b1%ec%a4%80-30802%eb%b2%88-%ec%9b%b0%ec%bb%b4-%ed%82%a4%ed%8a%b8-c-baekjoon/39921/#respond</comments>
		
		<dc:creator><![CDATA[lycos7560]]></dc:creator>
		<pubDate>Tue, 24 Sep 2024 09:03:38 +0000</pubDate>
				<category><![CDATA[BaekjoonOnlineJudge]]></category>
		<category><![CDATA[C++/CPP]]></category>
		<category><![CDATA[30802]]></category>
		<category><![CDATA[30802번]]></category>
		<category><![CDATA[Baekjoon]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[cpp]]></category>
		<category><![CDATA[study]]></category>
		<category><![CDATA[공부]]></category>
		<category><![CDATA[구현]]></category>
		<category><![CDATA[기초]]></category>
		<category><![CDATA[백준]]></category>
		<category><![CDATA[백준 30802번]]></category>
		<category><![CDATA[사칙연산]]></category>
		<category><![CDATA[수학]]></category>
		<category><![CDATA[알고리즘]]></category>
		<category><![CDATA[웰컴 키트]]></category>
		<category><![CDATA[코딩테스트]]></category>
		<category><![CDATA[코테]]></category>
		<guid isPermaLink="false">https://lycos7560.com/?p=39921</guid>

					<description><![CDATA[<p>웰컴 키트 https://www.acmicpc.net/problem/30802 시간 제한 메모리 제한 제출 정답 맞힌 사람 정답 비율 0.1 초 1024 MB 22145 11853 11012 53.443% 문제 2024년 2월 3일 개최 예정인 온사이트 그랜드 아레나에서는 참가자들에게 티셔츠 한 장과 펜 한 자루가 포함된 웰컴 키트를 나눠줄 예정입니다. 키트를 제작하는 업체는 다음과 같은 조건으로만 주문이 가능합니다. 총 N명의 참가자 중 S, M, [&#8230;]</p>
<p>The post <a href="https://lycos7560.com/cpp/%eb%b0%b1%ec%a4%80-30802%eb%b2%88-%ec%9b%b0%ec%bb%b4-%ed%82%a4%ed%8a%b8-c-baekjoon/39921/">백준 30802번 (웰컴 키트, C++) [BAEKJOON]</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading">웰컴 키트 <img decoding="async" width="30" height="38" class="wp-image-37924" style="width: 30px;" src="https://lycos7560.com/wp-content/uploads/2024/03/Bronze_3.jpg" alt="" srcset="https://lycos7560.com/wp-content/uploads/2024/03/Bronze_3.jpg 1250w, https://lycos7560.com/wp-content/uploads/2024/03/Bronze_3-234x300.jpg 234w, https://lycos7560.com/wp-content/uploads/2024/03/Bronze_3-768x983.jpg 768w, https://lycos7560.com/wp-content/uploads/2024/03/Bronze_3-1200x1536.jpg 1200w" sizes="(max-width: 30px) 100vw, 30px" /></h2>



<p><a href="https://www.acmicpc.net/problem/30802" target="_blank" rel="noreferrer noopener">https://www.acmicpc.net/problem/30802</a></p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><th class="has-text-align-left" data-align="left">시간 제한</th><th class="has-text-align-left" data-align="left">메모리 제한</th><th class="has-text-align-left" data-align="left">제출</th><th class="has-text-align-left" data-align="left">정답</th><th class="has-text-align-left" data-align="left">맞힌 사람</th><th class="has-text-align-left" data-align="left">정답 비율</th></tr></thead><tbody><tr><td class="has-text-align-left" data-align="left">0.1 초</td><td class="has-text-align-left" data-align="left">1024 MB</td><td class="has-text-align-left" data-align="left">22145</td><td class="has-text-align-left" data-align="left">11853</td><td class="has-text-align-left" data-align="left">11012</td><td class="has-text-align-left" data-align="left">53.443%</td></tr></tbody></table></figure>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading">문제</h3>



<p>2024년 2월 3일 개최 예정인 온사이트 그랜드 아레나에서는 참가자들에게 티셔츠 한 장과 펜 한 자루가 포함된 웰컴 키트를 나눠줄 예정입니다. </p>



<p>키트를 제작하는 업체는 다음과 같은 조건으로만 주문이 가능합니다.</p>



<ul class="wp-block-list">
<li>티셔츠는 S, M, L, XL, XXL, 그리고 XXXL의 6가지 사이즈가 있습니다. 티셔츠는 같은 사이즈의 T장 묶음으로만 주문할 수 있습니다.</li>



<li>펜은 한 종류로, P자루씩 묶음으로 주문하거나 한 자루씩 주문할 수 있습니다.</li>
</ul>



<p>총 N명의 참가자 중 S, M, L, XL, XXL, XXXL 사이즈의 티셔츠를 신청한 사람은 각각 S,M,L,XL,XXL,XXXL명입니다. </p>



<p>티셔츠는 남아도 되지만 부족해서는 안 되고 신청한 사이즈대로 나눠주어야 합니다. </p>



<p>펜은 남거나 부족해서는 안 되고 정확히 참가자 수만큼 준비되어야 합니다.</p>



<p>티셔츠를 T장씩 최소 몇 묶음 주문해야 하는지, 그리고 펜을 P자루씩 최대 몇 묶음 주문할 수 있고, 그 때 펜을 한 자루씩 몇 개 주문하는지 구하세요.</p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading">입력</h3>



<p>첫 줄에 참가자의 수 N이 주어집니다. <img decoding="async" width="109" height="25" class="wp-image-39922" style="width: 109px;" src="https://lycos7560.com/wp-content/uploads/2025/03/image-8.png" alt=""></p>



<p>둘째 줄에 티셔츠 사이즈별 신청자의 수 S, M, L, XL , XXL, XXXL이 공백으로 구분되어 주어집니다.  (0 ≤ S, M, L, XL, XXL, XXXL ≤ N; S + M + L + XL + XXL + XXXL = N)</p>



<p>셋째 줄에 정수 티셔츠와 펜의 묶음 수를 의미하는 정수 T와 P가 공백으로 구분되어 주어집니다. <img decoding="async" width="127" height="23" class="wp-image-39923" style="width: 127px;" src="https://lycos7560.com/wp-content/uploads/2025/03/image-9.png" alt=""></p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading">출력</h3>



<p>첫 줄에 티셔츠를 T장씩 최소 몇 묶음 주문해야 하는지 출력하세요.</p>



<p>다음 줄에 펜을 P자루씩 최대 몇 묶음 주문할 수 있는지와, 그 때 펜을 한 자루씩 몇 개 주문하는지 구하세요.</p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading">예제 입력 1</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">23
3 1 4 1 5 9
5 7</pre>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading">예제 출력 1</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">7
3 2</pre>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<p>S, M, L, XL, XXL 사이즈 티셔츠를 1 묶음씩 구매하고 XXXL 사이즈 티셔츠를 2묶음 구매합니다.</p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading">출처</h3>



<p><a href="https://www.acmicpc.net/category/45" target="_blank" rel="noreferrer noopener">Contest</a> > <a href="https://www.acmicpc.net/category/859" target="_blank" rel="noreferrer noopener">solved.ac</a> > <a href="https://www.acmicpc.net/category/1003" target="_blank" rel="noreferrer noopener">solved.ac Grand Arena #3</a> > <a href="https://www.acmicpc.net/category/detail/4059" target="_blank" rel="noreferrer noopener">Division 2</a> A번</p>



<ul class="wp-block-list">
<li>문제를 검수한 사람: <a href="https://www.acmicpc.net/user/cologne" target="_blank" rel="noreferrer noopener">cologne</a>, <a href="https://www.acmicpc.net/user/cozyyg" target="_blank" rel="noreferrer noopener">cozyyg</a>, <a href="https://www.acmicpc.net/user/gs18115" target="_blank" rel="noreferrer noopener">gs18115</a>, <a href="https://www.acmicpc.net/user/seonah" target="_blank" rel="noreferrer noopener">seonah</a>, <a href="https://www.acmicpc.net/user/shiftpsh" target="_blank" rel="noreferrer noopener">shiftpsh</a></li>



<li>문제를 만든 사람: <a href="https://www.acmicpc.net/user/havana723" target="_blank" rel="noreferrer noopener">havana723</a>, <a href="https://www.acmicpc.net/user/solvedac" target="_blank" rel="noreferrer noopener">solvedac</a></li>
</ul>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading">알고리즘 분류</h3>



<ul class="wp-block-list">
<li><a href="https://www.acmicpc.net/problem/tag/124" target="_blank" rel="noreferrer noopener">수학</a></li>



<li><a href="https://www.acmicpc.net/problem/tag/102" target="_blank" rel="noreferrer noopener">구현</a></li>



<li><a href="https://www.acmicpc.net/problem/tag/121" target="_blank" rel="noreferrer noopener">사칙연산</a></li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity is-style-wide" style="margin-top:var(--wp--preset--spacing--80);margin-bottom:var(--wp--preset--spacing--80)"/>



<h3 class="wp-block-heading">통과된 코드</h3>



<p>단순한 사칙 연산을 구현하는 문제</p>



<p>문제의 내용을 그대로 구현만 하면 되어서 별다른 로직이 없다.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="cpp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#include &lt;iostream>

using namespace std;

int N, S, M, L, XL, XXL, XXXL, T, P;

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    cin >> N >> S >> M >> L >> XL >> XXL >> XXXL >> T >> P;

    int Res = 0;
    
    Res += (int)(S / T) + (int)(M / T) + (int)(L / T) + (int)(XL / T) + (int)(XXL / T) + (int)(XXXL / T);
    if (S % T > 0) Res++;
    if (M % T > 0) Res++;
    if (L % T > 0) Res++;
    if (XL % T > 0) Res++;
    if (XXL % T > 0) Res++;
    if (XXXL % T > 0) Res++;

    cout &lt;&lt; Res &lt;&lt; "\n";
    cout &lt;&lt; (int)(N / P) &lt;&lt; " " &lt;&lt; N % P;

    return 0;
}
</pre>



<p></p>
<p>The post <a href="https://lycos7560.com/cpp/%eb%b0%b1%ec%a4%80-30802%eb%b2%88-%ec%9b%b0%ec%bb%b4-%ed%82%a4%ed%8a%b8-c-baekjoon/39921/">백준 30802번 (웰컴 키트, C++) [BAEKJOON]</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://lycos7560.com/cpp/%eb%b0%b1%ec%a4%80-30802%eb%b2%88-%ec%9b%b0%ec%bb%b4-%ed%82%a4%ed%8a%b8-c-baekjoon/39921/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>백준 12924번 (멋진 쌍, C++) [BAEKJOON]</title>
		<link>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-12924%eb%b2%88-%eb%a9%8b%ec%a7%84-%ec%8c%8d-c-baekjoon/36435/</link>
					<comments>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-12924%eb%b2%88-%eb%a9%8b%ec%a7%84-%ec%8c%8d-c-baekjoon/36435/#respond</comments>
		
		<dc:creator><![CDATA[lycos7560]]></dc:creator>
		<pubDate>Wed, 09 Aug 2023 04:47:07 +0000</pubDate>
				<category><![CDATA[BaekjoonOnlineJudge]]></category>
		<category><![CDATA[C++/CPP]]></category>
		<category><![CDATA[12924]]></category>
		<category><![CDATA[12924번]]></category>
		<category><![CDATA[Baekjoon]]></category>
		<category><![CDATA[brute force]]></category>
		<category><![CDATA[BruteForce]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[cpp]]></category>
		<category><![CDATA[study]]></category>
		<category><![CDATA[공부]]></category>
		<category><![CDATA[기초]]></category>
		<category><![CDATA[멋진 쌍]]></category>
		<category><![CDATA[백준]]></category>
		<category><![CDATA[백준 12924]]></category>
		<category><![CDATA[백준 12924번]]></category>
		<category><![CDATA[브루트 포스]]></category>
		<category><![CDATA[수학]]></category>
		<category><![CDATA[알고리즘]]></category>
		<category><![CDATA[코딩테스트]]></category>
		<category><![CDATA[코테]]></category>
		<guid isPermaLink="false">https://lycos7560.com/?p=36435</guid>

					<description><![CDATA[<p>백준 12924번 '멋진 쌍' 문제에 대한 글입니다. '브루트포스' 알고리즘을 이용하여 문제를 해결하였습니다. (This article is about Baekjoon Number 12924 "Cool Pair" problem. We solved the problem using the 'Brute Force' algorithm.)</p>
<p>The post <a href="https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-12924%eb%b2%88-%eb%a9%8b%ec%a7%84-%ec%8c%8d-c-baekjoon/36435/">백준 12924번 (멋진 쌍, C++) [BAEKJOON]</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-5698326622209671"
     crossorigin="anonymous"></script>
<ins class="adsbygoogle"
     style="display:block; text-align:center;"
     data-ad-layout="in-article"
     data-ad-format="fluid"
     data-ad-client="ca-pub-5698326622209671"
     data-ad-slot="5078714126"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>



<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>


				<div class="wp-block-uagb-table-of-contents uagb-toc__align-left uagb-toc__columns-1  uagb-block-1efa480d      "
					data-scroll= "1"
					data-offset= "30"
					style=""
				>
				<div class="uagb-toc__wrap">
						<div class="uagb-toc__title">
							목차 테이블						</div>
																						<div class="uagb-toc__list-wrap ">
						<ol class="uagb-toc__list"><li class="uagb-toc__list"><a href="#멋진-쌍" class="uagb-toc-link__trigger">멋진 쌍</a><ul class="uagb-toc__list"><li class="uagb-toc__list"><a href="#통과된-코드" class="uagb-toc-link__trigger">통과된 코드</a></ul></ol>					</div>
									</div>
				</div>
			


<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>



<h1 class="wp-block-heading">멋진 쌍</h1>



<p><a href="https://www.acmicpc.net/problem/12924">https://www.acmicpc.net/problem/12924</a></p>



<div style="height:50px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><th class="has-text-align-left" data-align="left">시간 제한</th><th class="has-text-align-left" data-align="left">메모리 제한</th><th class="has-text-align-left" data-align="left">제출</th><th class="has-text-align-left" data-align="left">정답</th><th class="has-text-align-left" data-align="left">맞힌 사람</th><th class="has-text-align-left" data-align="left">정답 비율</th></tr></thead><tbody><tr><td class="has-text-align-left" data-align="left">2 초</td><td class="has-text-align-left" data-align="left">512 MB</td><td class="has-text-align-left" data-align="left">238</td><td class="has-text-align-left" data-align="left">88</td><td class="has-text-align-left" data-align="left">76</td><td class="has-text-align-left" data-align="left">38.191%</td></tr></tbody></table></figure>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">문제</h3>



<p>두 자연수 (n, m)이 멋진 쌍일 조건은 다음과 같다.</p>



<ul class="wp-block-list">
<li>n의 뒤에서 몇 자리를 떼서, 앞에 그대로 붙이면 m을 얻을 수 있다.</li>
</ul>



<p>예를 들어, 12345의 뒤에서 345를 떼서 앞에 붙이면 34512가 되므로, (12345, 34512)는 멋진 쌍이다.</p>



<p>같은 개수의 자릿수를 갖는 두 자연수 A와 B가 주어질 때, A ≤ x &lt;&nbsp;y ≤ B 인 멋진 쌍 (x, y)의 개수를 출력하세요.</p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">입력</h3>



<p>첫 번째 줄에 두 자연수 A, B가 주어진다. A ≤ B ≤ 2,000,000, A와 B의 자릿수 개수는 같다.</p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">출력</h3>



<p>멋진 쌍의 개수를 자연수 하나로 출력한다.</p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">예제 입력 1</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">1 9</pre>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">예제 출력 1</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">0</pre>



<div style="height:50px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">예제 입력 2</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">10 40</pre>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">예제 출력 2</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">3</pre>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">예제 입력 3</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">100 500</pre>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">예제 출력 3</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">156</pre>



<div style="height:50px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">알고리즘 분류</h3>



<ul class="wp-block-list">
<li><a href="https://www.acmicpc.net/problem/tag/124" target="_blank" rel="noreferrer noopener">수학</a></li>



<li><a href="https://www.acmicpc.net/problem/tag/125" target="_blank" rel="noreferrer noopener">브루트포스 알고리즘</a></li>
</ul>



<div style="height:50px" aria-hidden="true" class="wp-block-spacer"></div>



<hr class="wp-block-separator has-alpha-channel-opacity is-style-wide" style="margin-top:var(--wp--preset--spacing--80);margin-bottom:var(--wp--preset--spacing--80)"/>



<h2 class="wp-block-heading has-large-font-size">통과된 코드</h2>



<p>중복을 제거하지 않으면 오답으로 처리됩니다.</p>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<pre class="EnlighterJSRAW" data-enlighter-language="cpp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#include &lt;iostream>
#include &lt;string>
#include &lt;cmath>
#include &lt;set>
using namespace std;
set&lt;pair&lt;int, int>> _ResSet;
int _A, _B, _Res;
int FindingDigit(int _number)
{
	int dig = 0;
	while (_number) {
		_number /= 10;
		dig++;
	}
	return dig;
}

int main()
{
	cin >> _A >> _B;
	for (int i = _A; i &lt;= _B; i++) {
		int dig = FindingDigit(i);
		_ResSet.clear();
		for (int j = 1; j &lt;= dig - 1; j++) {
			int number = i;
			int _t = pow(10, j);
			int remainder = number % _t;
			int frontpart = number / _t;
			int frontpartDig = FindingDigit(frontpart);
			_t = pow(10, frontpartDig);
			int res = frontpart + (remainder * _t);
			if (dig != FindingDigit(res))
				continue;
			if (res > _B || res &lt; _A || res &lt;= number)
				continue;
			_ResSet.insert({ number, res });
		}
		_Res += _ResSet.size();
	}
	cout &lt;&lt; _Res;
	return 0;
}</pre>



<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-image size-full"><img decoding="async" width="1207" height="99" src="https://lycos7560.com/wp-content/uploads/2023/08/image-3.png" alt="" class="wp-image-36447" srcset="https://lycos7560.com/wp-content/uploads/2023/08/image-3.png 1207w, https://lycos7560.com/wp-content/uploads/2023/08/image-3-300x25.png 300w, https://lycos7560.com/wp-content/uploads/2023/08/image-3-768x63.png 768w" sizes="(max-width: 1207px) 100vw, 1207px" /></figure>



<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>



<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-5698326622209671"
     crossorigin="anonymous"></script>
<ins class="adsbygoogle"
     style="display:block"
     data-ad-format="autorelaxed"
     data-ad-client="ca-pub-5698326622209671"
     data-ad-slot="4386247858"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
<p>The post <a href="https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-12924%eb%b2%88-%eb%a9%8b%ec%a7%84-%ec%8c%8d-c-baekjoon/36435/">백준 12924번 (멋진 쌍, C++) [BAEKJOON]</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-12924%eb%b2%88-%eb%a9%8b%ec%a7%84-%ec%8c%8d-c-baekjoon/36435/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>백준 4811번 (알약, C++) [BAEKJOON]</title>
		<link>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-4811%eb%b2%88-%ec%95%8c%ec%95%bd-c-baekjoon/36232/</link>
					<comments>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-4811%eb%b2%88-%ec%95%8c%ec%95%bd-c-baekjoon/36232/#respond</comments>
		
		<dc:creator><![CDATA[lycos7560]]></dc:creator>
		<pubDate>Thu, 20 Jul 2023 04:39:11 +0000</pubDate>
				<category><![CDATA[BaekjoonOnlineJudge]]></category>
		<category><![CDATA[C++/CPP]]></category>
		<category><![CDATA[4811]]></category>
		<category><![CDATA[4811번]]></category>
		<category><![CDATA[Baekjoon]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[cpp]]></category>
		<category><![CDATA[DP]]></category>
		<category><![CDATA[DynamicProgramming]]></category>
		<category><![CDATA[study]]></category>
		<category><![CDATA[공부]]></category>
		<category><![CDATA[기초]]></category>
		<category><![CDATA[다이나믹 프로그래밍]]></category>
		<category><![CDATA[백준]]></category>
		<category><![CDATA[백준 4811]]></category>
		<category><![CDATA[백준 4811번]]></category>
		<category><![CDATA[수학]]></category>
		<category><![CDATA[알고리즘]]></category>
		<category><![CDATA[알약]]></category>
		<category><![CDATA[코딩테스트]]></category>
		<category><![CDATA[코테]]></category>
		<guid isPermaLink="false">https://lycos7560.com/?p=36232</guid>

					<description><![CDATA[<p>백준 4811번 ' 알약 ' 문제에 대한 글입니다. 다이나믹 프로그래밍을 이용하여 해결하였습니다. (This is an article about the 'pill' problem of Baekjoon Number 4811. It was solved using dynamic programming.)</p>
<p>The post <a href="https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-4811%eb%b2%88-%ec%95%8c%ec%95%bd-c-baekjoon/36232/">백준 4811번 (알약, C++) [BAEKJOON]</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<script async="" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-5698326622209671" crossorigin="anonymous"></script>
<!-- HorizontalAD -->
<ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-5698326622209671" data-ad-slot="6908948342" data-ad-format="auto" data-full-width-responsive="true"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>



<div style="height:62px" aria-hidden="true" class="wp-block-spacer"></div>


				<div class="wp-block-uagb-table-of-contents uagb-toc__align-left uagb-toc__columns-1  uagb-block-355fab5d      "
					data-scroll= "1"
					data-offset= "30"
					style=""
				>
				<div class="uagb-toc__wrap">
						<div class="uagb-toc__title">
							목차 테이블						</div>
																						<div class="uagb-toc__list-wrap ">
						<ol class="uagb-toc__list"><li class="uagb-toc__list"><a href="#알약" class="uagb-toc-link__trigger">알약</a><ul class="uagb-toc__list"><li class="uagb-toc__list"><a href="#통과된-코드" class="uagb-toc-link__trigger">통과된 코드</a></ul></ol>					</div>
									</div>
				</div>
			


<div style="height:62px" aria-hidden="true" class="wp-block-spacer"></div>



<h1 class="wp-block-heading">알약</h1>



<p><a href="https://www.acmicpc.net/problem/4811" target="_blank" rel="noreferrer noopener">https://www.acmicpc.net/problem/4811</a></p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><th class="has-text-align-left" data-align="left">시간 제한</th><th class="has-text-align-left" data-align="left">메모리 제한</th><th class="has-text-align-left" data-align="left">제출</th><th class="has-text-align-left" data-align="left">정답</th><th class="has-text-align-left" data-align="left">맞힌 사람</th><th class="has-text-align-left" data-align="left">정답 비율</th></tr></thead><tbody><tr><td class="has-text-align-left" data-align="left">1 초</td><td class="has-text-align-left" data-align="left">256 MB</td><td class="has-text-align-left" data-align="left">6484</td><td class="has-text-align-left" data-align="left">4179</td><td class="has-text-align-left" data-align="left">3230</td><td class="has-text-align-left" data-align="left">66.901%</td></tr></tbody></table></figure>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">문제</h3>



<p>70세 박종수 할아버지는 매일 매일 약 반알을 먹는다. </p>



<p>손녀 선영이는 종수 할아버지에게 약이 N개 담긴 병을 선물로 주었다.</p>



<p>첫째 날에 종수는 병에서 약 하나를 꺼낸다. </p>



<p>그 다음, 그 약을 반으로 쪼개서 한 조각은 먹고, 다른 조각은 다시 병에 넣는다.</p>



<p>다음 날부터 종수는 병에서 약을 하나 꺼낸다. (약은 한 조각 전체 일 수도 있고, 쪼갠 반 조각 일 수도 있다) </p>



<p>반 조각이라면 그 약을 먹고, 아니라면 반을 쪼개서 한 조각을 먹고, 다른 조각은 다시 병에 넣는다.</p>



<p>종수는 손녀에게 한 조각을 꺼낸 날에는 W를, 반 조각을 꺼낸 날에는 H 보낸다. </p>



<p>손녀는 할아버지에게 받은 문자를 종이에 기록해 놓는다. </p>



<p>총 2N일이 지나면 길이가 2N인 문자열이 만들어지게 된다. </p>



<p>이때, 가능한 서로 다른 문자열의 개수는 총 몇 개일까?</p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">입력</h3>



<p>입력은 최대 1000개의 테스트 케이스로 이루어져 있다. </p>



<p>각 테스트 케이스는 한 줄이며, 병에 들어있는 약의 개수 N ≤ 30 가 주어진다.</p>



<p>입력의 마지막 줄에는 0이 하나 주어진다.</p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">출력</h3>



<p>각 테스트 케이스에 대해서 가능한 문자열의 개수를 출력한다.</p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">예제 입력 1</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">6
1
4
2
3
30
0</pre>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">예제 출력 1</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">132
1
14
2
5
3814986502092304</pre>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">출처</h3>



<p><a href="https://www.acmicpc.net/category/1" target="_blank" rel="noreferrer noopener">ICPC</a>&nbsp;&gt;&nbsp;<a href="https://www.acmicpc.net/category/7" target="_blank" rel="noreferrer noopener">Regionals</a>&nbsp;&gt;&nbsp;<a href="https://www.acmicpc.net/category/8" target="_blank" rel="noreferrer noopener">North America</a>&nbsp;&gt;&nbsp;<a href="https://www.acmicpc.net/category/41" target="_blank" rel="noreferrer noopener">Rocky Mountain Regional</a>&nbsp;&gt;&nbsp;<a href="https://www.acmicpc.net/category/detail/182" target="_blank" rel="noreferrer noopener">2011 Rocky Mountain Regional Contest</a>&nbsp;E번</p>



<ul class="wp-block-list">
<li>문제를 번역한 사람:&nbsp;<a href="https://www.acmicpc.net/user/baekjoon" target="_blank" rel="noreferrer noopener">baekjoon</a></li>
</ul>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">알고리즘 분류</h3>



<ul class="wp-block-list">
<li><a href="https://www.acmicpc.net/problem/tag/124" target="_blank" rel="noreferrer noopener">수학</a></li>



<li><a href="https://www.acmicpc.net/problem/tag/25" target="_blank" rel="noreferrer noopener">다이나믹 프로그래밍</a></li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity is-style-wide" style="margin-top:var(--wp--preset--spacing--80);margin-bottom:var(--wp--preset--spacing--80)"/>



<figure class="wp-block-image size-full is-resized"><img decoding="async" src="https://lycos7560.com/wp-content/uploads/2023/07/image-44.png" alt="" class="wp-image-36252" width="734" height="788" srcset="https://lycos7560.com/wp-content/uploads/2023/07/image-44.png 978w, https://lycos7560.com/wp-content/uploads/2023/07/image-44-279x300.png 279w, https://lycos7560.com/wp-content/uploads/2023/07/image-44-768x825.png 768w" sizes="(max-width: 734px) 100vw, 734px" /></figure>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading has-large-font-size">통과된 코드</h2>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<pre class="EnlighterJSRAW" data-enlighter-language="cpp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#include &lt;iostream>
using namespace std;
int _N;
long long int _DP[31][31];
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	for (int i = 0; i &lt;= 30; i++)
		for (int j = 0; j &lt;= 30; j++) {
			// 반쪽이 더 많은 경우는 없다.
			if (i &lt; j) break;
			if (j == 0) _DP[i][j] = 1;
			else _DP[i][j] = _DP[i - 1][j] + _DP[i][j - 1];
		}

	while (true) {
		cin >> _N;
		if (_N == 0) break;
		// 온전한 알약을 N번
		// 반쪽의 알약을 N번 => 다 먹었다.
		cout &lt;&lt; _DP[_N][_N] &lt;&lt; "\n";
	}

	return 0;
}</pre>



<div style="height:50px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-image size-full"><img decoding="async" width="1206" height="104" src="https://lycos7560.com/wp-content/uploads/2023/07/image-43.png" alt="" class="wp-image-36241" srcset="https://lycos7560.com/wp-content/uploads/2023/07/image-43.png 1206w, https://lycos7560.com/wp-content/uploads/2023/07/image-43-300x26.png 300w, https://lycos7560.com/wp-content/uploads/2023/07/image-43-768x66.png 768w" sizes="(max-width: 1206px) 100vw, 1206px" /></figure>



<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>



<script async="" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-5698326622209671" crossorigin="anonymous"></script>
<ins class="adsbygoogle" style="display:block" data-ad-format="autorelaxed" data-ad-client="ca-pub-5698326622209671" data-ad-slot="4245812909"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
<p>The post <a href="https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-4811%eb%b2%88-%ec%95%8c%ec%95%bd-c-baekjoon/36232/">백준 4811번 (알약, C++) [BAEKJOON]</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-4811%eb%b2%88-%ec%95%8c%ec%95%bd-c-baekjoon/36232/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>알고리즘 – 비둘기 집의 원리 (Pigeonhole Principle)</title>
		<link>https://lycos7560.com/etc/%ec%95%8c%ea%b3%a0%eb%a6%ac%ec%a6%98-%eb%b9%84%eb%91%98%ea%b8%b0-%ec%a7%91%ec%9d%98-%ec%9b%90%eb%a6%ac-pigeonhole-principle/36080/</link>
					<comments>https://lycos7560.com/etc/%ec%95%8c%ea%b3%a0%eb%a6%ac%ec%a6%98-%eb%b9%84%eb%91%98%ea%b8%b0-%ec%a7%91%ec%9d%98-%ec%9b%90%eb%a6%ac-pigeonhole-principle/36080/#respond</comments>
		
		<dc:creator><![CDATA[lycos7560]]></dc:creator>
		<pubDate>Fri, 14 Jul 2023 22:24:30 +0000</pubDate>
				<category><![CDATA[기타]]></category>
		<category><![CDATA[Pigeonhole]]></category>
		<category><![CDATA[Pigeonhole Principle]]></category>
		<category><![CDATA[study]]></category>
		<category><![CDATA[공부]]></category>
		<category><![CDATA[기본]]></category>
		<category><![CDATA[기초]]></category>
		<category><![CDATA[비둘기]]></category>
		<category><![CDATA[비둘기 집의 원리]]></category>
		<category><![CDATA[수학]]></category>
		<category><![CDATA[알고리즘]]></category>
		<category><![CDATA[이산 수학]]></category>
		<category><![CDATA[이산수학]]></category>
		<category><![CDATA[코딩테스트]]></category>
		<category><![CDATA[코테]]></category>
		<guid isPermaLink="false">https://lycos7560.com/?p=36080</guid>

					<description><![CDATA[<p>비둘기 집의 원리에 대한 블로그 게시글입니다. (A blog post about the principles of pigeon houses.)</p>
<p>The post <a href="https://lycos7560.com/etc/%ec%95%8c%ea%b3%a0%eb%a6%ac%ec%a6%98-%eb%b9%84%eb%91%98%ea%b8%b0-%ec%a7%91%ec%9d%98-%ec%9b%90%eb%a6%ac-pigeonhole-principle/36080/">알고리즘 – 비둘기 집의 원리 (Pigeonhole Principle)</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<script async="" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-5698326622209671" crossorigin="anonymous"></script>
<!-- HorizontalAD -->
<ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-5698326622209671" data-ad-slot="6908948342" data-ad-format="auto" data-full-width-responsive="true"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>



<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>


				<div class="wp-block-uagb-table-of-contents uagb-toc__align-left uagb-toc__columns-1  uagb-block-59188d43      "
					data-scroll= "1"
					data-offset= "30"
					style=""
				>
				<div class="uagb-toc__wrap">
						<div class="uagb-toc__title">
							목차 테이블						</div>
																						<div class="uagb-toc__list-wrap ">
						<ol class="uagb-toc__list"><li class="uagb-toc__list"><a href="#비둘기-집의-원리" class="uagb-toc-link__trigger">비둘기 집의 원리</a><ul class="uagb-toc__list"><li class="uagb-toc__list"><a href="#증명" class="uagb-toc-link__trigger">증명</a><li class="uagb-toc__list"><li class="uagb-toc__list"><a href="#비둘기집의-원리의-일반화" class="uagb-toc-link__trigger">비둘기집의 원리의 일반화</a><li class="uagb-toc__list"><li class="uagb-toc__list"><a href="#관련-문제" class="uagb-toc-link__trigger">관련 문제</a></ul></ol>					</div>
									</div>
				</div>
			


<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>



<h1 class="wp-block-heading has-large-font-size">비둘기 집의 원리</h1>



<hr class="wp-block-separator has-alpha-channel-opacity is-style-wide"/>



<p><em>n</em>+1개의 물건을<em> n</em>개의 상자에 넣은 경우, 최소한 한 상자에는 그 물건이 반드시 두 개 이상 들어있다는 원리를 말한다. </p>



<p>보통 비둘기와 비둘기집의 형태로 비유되어 쓰이기 때문에, 비둘기 집의 원리라고 불린다.</p>



<figure class="wp-block-image size-full"><img decoding="async" width="780" height="420" src="https://lycos7560.com/wp-content/uploads/2023/07/image-34.png" alt="" class="wp-image-36084" srcset="https://lycos7560.com/wp-content/uploads/2023/07/image-34.png 780w, https://lycos7560.com/wp-content/uploads/2023/07/image-34-300x162.png 300w, https://lycos7560.com/wp-content/uploads/2023/07/image-34-768x414.png 768w" sizes="(max-width: 780px) 100vw, 780px" /></figure>



<p>비둘기가 10마리, 집이 9개라면 한마리가 남는다.</p>



<div style="height:150px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading has-large-font-size">증명</h2>



<hr class="wp-block-separator has-alpha-channel-opacity is-style-wide"/>



<p>간단한 귀류법으로 증명할 수 있다. </p>



<p>모든 비둘기가 집에 들어간다는 가정 하에</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p><img decoding="async" src="https://wikimedia.org/api/rest_v1/media/math/render/svg/a601995d55609f2d9f5e233e36fbe9ea26011b3b" alt="n">개의 비둘기집과 <img decoding="async" src="https://wikimedia.org/api/rest_v1/media/math/render/svg/2a135e65a42f2d73cccbfc4569523996ca0036f1" alt="n+1">마리의 비둘기가 있다고 가정한다.<br>만약 각 비둘기집에 한 마리 이하의 비둘기만 들어 있다면, 전체 비둘기집에는 많아야 <img decoding="async" src="https://wikimedia.org/api/rest_v1/media/math/render/svg/a601995d55609f2d9f5e233e36fbe9ea26011b3b" alt="n">마리의 비둘기가 존재한다. <br>그런데 비둘기는 모두 <img decoding="async" src="https://wikimedia.org/api/rest_v1/media/math/render/svg/2a135e65a42f2d73cccbfc4569523996ca0036f1" alt="n+1">마리이므로, 이것은 모순이다. <br>따라서 어느 비둘기집에는 두 마리 이상의 비둘기가 있다.</p>
</blockquote>



<p>이 증명은 대표적인 존재증명이다. </p>



<p>즉, 비둘기가 두 마리 이상 존재하는 집이 정확히 어떤 집인지는 이 증명으로 알아낼 수 없다.</p>



<div style="height:150px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading has-large-font-size">비둘기집의 원리의 일반화</h2>



<hr class="wp-block-separator has-alpha-channel-opacity is-style-wide"/>



<p>일반화된 비둘기집 원리는 다음과 같다.</p>



<p><img decoding="async" src="https://wikimedia.org/api/rest_v1/media/math/render/svg/a601995d55609f2d9f5e233e36fbe9ea26011b3b" alt="n">개의 별개의 사물을 <img decoding="async" src="https://wikimedia.org/api/rest_v1/media/math/render/svg/0a07d98bb302f3856cbabc47b2b9016692e3f7bc" alt="m">개의 용기에 나누어 담으면 적어도 한 개의 용기는 <img decoding="async" src="https://wikimedia.org/api/rest_v1/media/math/render/svg/81e801db1dafe4401bb060b3851dd318595a5bed" alt="\left\lceil {\frac  nm}\right\rceil "> 이상의 사물을 담고 있어야 한다. </p>



<p>(여기서, <img decoding="async" src="https://wikimedia.org/api/rest_v1/media/math/render/svg/5ac7f37c8288700904b4a22a2f7c94d45ba917de" alt="\lceil x\rceil ">는 <img decoding="async" src="https://wikimedia.org/api/rest_v1/media/math/render/svg/87f9e315fd7e2ba406057a97300593c4802b53e4" alt="x">보다 작지 않은 최소 정수를 의미한다.)</p>



<p>확률론적으로 일반화된 비둘기집 원리는 다음과 같다.</p>



<p><img decoding="async" src="https://wikimedia.org/api/rest_v1/media/math/render/svg/6dbabfa67f5f4f81ea6c073d5b9d8f05df383972" alt="{\frac  1m}">의 균일한 확률로 <img decoding="async" src="https://wikimedia.org/api/rest_v1/media/math/render/svg/a601995d55609f2d9f5e233e36fbe9ea26011b3b" alt="n">개의 비둘기를 무작위로 <img decoding="async" src="https://wikimedia.org/api/rest_v1/media/math/render/svg/0a07d98bb302f3856cbabc47b2b9016692e3f7bc" alt="m">개의 비둘기집에 넣었다면 확률적으로 적어도 하나의 비둘기집에 두마리 이상의 비둘기가 들어가게 된다.</p>



<p><img decoding="async" src="https://wikimedia.org/api/rest_v1/media/math/render/svg/5595f881d4015ee09def36a7482be8661865b053" alt="1-{\frac  {m!}{(m-n)!\;m^{n}}}=1-{\frac  {m(m-1)(m-2)\cdots (m-n+1)}{m^{n}}}\!"></p>



<p><img decoding="async" src="https://wikimedia.org/api/rest_v1/media/math/render/svg/26819344e55f5e671c76c07c18eb4291fcec85ae" alt="n=0"> 인 경우와, <img decoding="async" src="https://wikimedia.org/api/rest_v1/media/math/render/svg/d9ec7e1edc2e6d98f5aec2a39ae5f1c99d1e1425" alt="n=1">인 경우(단, <img decoding="async" src="https://wikimedia.org/api/rest_v1/media/math/render/svg/501173910e6da8425b4e9d44a4e8643620bc2464" alt="m&gt;0">)에 확률은 0인데, 달리 말하면 비둘기가 한마리 밖에 없다고 하면, </p>



<p>충돌(한 비둘기집에 두 마리 이상의 비둘기가 들어가는 일)이 일어날 수 없다는 것이다. </p>



<p><img decoding="async" src="https://wikimedia.org/api/rest_v1/media/math/render/svg/e64e2a4a5b6cb58f1553c6a65551b4898bb82403" alt="n&gt;m"> (비둘기가 비둘기집보다 많다)이라면 확률은 1이 되고 이런 경우에는 보통의 비둘기집 원리와 같은 일이 일어난다. </p>



<p>그러나 비둘기의 수가 비둘기집의 수를 초과하지 않는다 하더라도 (<img decoding="async" src="https://wikimedia.org/api/rest_v1/media/math/render/svg/1be80a749be067190db51891139a12d4886fc054" alt="n\leq m">), 비둘기 분배의 무작위적인 성질에 의하여 종종 상당한 확률로 충돌이 일어난다. </p>



<p>예를 들어, 2마리의 비둘기가 무작위로 4개의 비둘기집에 분배된다면, 25%의 확률로 적어도 하나의 비둘기집에 두마리 이상의 비둘기가 들어가게 될 것이며, </p>



<p>5마리의 비둘기를 10개의 비둘기집에 분배한다면 확률은 69.76%가 되고, 10마리의 비둘기를 20개의 비둘기집에 분배하면 그 확률은 약 93.45%가 된다.</p>



<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>



<p>출처 : <a href="https://ko.wikipedia.org/wiki/%EB%B9%84%EB%91%98%EA%B8%B0%EC%A7%91_%EC%9B%90%EB%A6%AC" target="_blank" rel="noreferrer noopener">https://ko.wikipedia.org/wiki/%EB%B9%84%EB%91%98%EA%B8%B0%EC%A7%91_%EC%9B%90%EB%A6%AC</a></p>



<div style="margin-top:0;margin-bottom:0;height:150px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading has-large-font-size">관련 문제</h2>



<hr class="wp-block-separator has-alpha-channel-opacity is-style-wide"/>



<div style="height:39px" aria-hidden="true" class="wp-block-spacer"></div>



<p>백준 20529번 가장 가까운 세 사람의 심리적 거리</p>



<p><a href="https://www.acmicpc.net/problem/20529">https://www.acmicpc.net/problem/20529</a></p>



<figure class="wp-block-embed is-type-wp-embed is-provider-어제와-내일의-나-그-사이의-이야기 wp-block-embed-어제와-내일의-나-그-사이의-이야기"><div class="wp-block-embed__wrapper">
<blockquote class="wp-embedded-content" data-secret="CODHwoEfpQ"><a href="https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-20529%eb%b2%88-%ea%b0%80%ec%9e%a5-%ea%b0%80%ea%b9%8c%ec%9a%b4-%ec%84%b8-%ec%82%ac%eb%9e%8c%ec%9d%98-%ec%8b%ac%eb%a6%ac%ec%a0%81-%ea%b1%b0%eb%a6%ac-c-baekjoon/36060/">백준 20529번 (가장 가까운 세 사람의 심리적 거리, C++) [BAEKJOON]</a></blockquote><iframe loading="lazy" class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  title="&#8220;백준 20529번 (가장 가까운 세 사람의 심리적 거리, C++) [BAEKJOON]&#8221; &#8212; 어제와 내일의 나 그 사이의 이야기" src="https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-20529%eb%b2%88-%ea%b0%80%ec%9e%a5-%ea%b0%80%ea%b9%8c%ec%9a%b4-%ec%84%b8-%ec%82%ac%eb%9e%8c%ec%9d%98-%ec%8b%ac%eb%a6%ac%ec%a0%81-%ea%b1%b0%eb%a6%ac-c-baekjoon/36060/embed/#?secret=3GS4lY6rks#?secret=CODHwoEfpQ" data-secret="CODHwoEfpQ" width="600" height="338" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe>
</div></figure>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<p>백준 비둘기 집의 원리 관련 문제들</p>



<p><a href="https://www.acmicpc.net/problemset?sort=ac_desc&amp;algo=189">https://www.acmicpc.net/problemset?sort=ac_desc&amp;algo=189</a></p>



<div style="height:50px" aria-hidden="true" class="wp-block-spacer"></div>



<script async="" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-5698326622209671" crossorigin="anonymous"></script>
<ins class="adsbygoogle" style="display:block" data-ad-format="autorelaxed" data-ad-client="ca-pub-5698326622209671" data-ad-slot="4245812909"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
<p>The post <a href="https://lycos7560.com/etc/%ec%95%8c%ea%b3%a0%eb%a6%ac%ec%a6%98-%eb%b9%84%eb%91%98%ea%b8%b0-%ec%a7%91%ec%9d%98-%ec%9b%90%eb%a6%ac-pigeonhole-principle/36080/">알고리즘 – 비둘기 집의 원리 (Pigeonhole Principle)</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://lycos7560.com/etc/%ec%95%8c%ea%b3%a0%eb%a6%ac%ec%a6%98-%eb%b9%84%eb%91%98%ea%b8%b0-%ec%a7%91%ec%9d%98-%ec%9b%90%eb%a6%ac-pigeonhole-principle/36080/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>백준 20529번 (가장 가까운 세 사람의 심리적 거리, C++) [BAEKJOON]</title>
		<link>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-20529%eb%b2%88-%ea%b0%80%ec%9e%a5-%ea%b0%80%ea%b9%8c%ec%9a%b4-%ec%84%b8-%ec%82%ac%eb%9e%8c%ec%9d%98-%ec%8b%ac%eb%a6%ac%ec%a0%81-%ea%b1%b0%eb%a6%ac-c-baekjoon/36060/</link>
					<comments>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-20529%eb%b2%88-%ea%b0%80%ec%9e%a5-%ea%b0%80%ea%b9%8c%ec%9a%b4-%ec%84%b8-%ec%82%ac%eb%9e%8c%ec%9d%98-%ec%8b%ac%eb%a6%ac%ec%a0%81-%ea%b1%b0%eb%a6%ac-c-baekjoon/36060/#comments</comments>
		
		<dc:creator><![CDATA[lycos7560]]></dc:creator>
		<pubDate>Fri, 14 Jul 2023 22:16:16 +0000</pubDate>
				<category><![CDATA[BaekjoonOnlineJudge]]></category>
		<category><![CDATA[C++/CPP]]></category>
		<category><![CDATA[20529]]></category>
		<category><![CDATA[20529번]]></category>
		<category><![CDATA[Baekjoon]]></category>
		<category><![CDATA[bit]]></category>
		<category><![CDATA[brute force]]></category>
		<category><![CDATA[BruteForce]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[cpp]]></category>
		<category><![CDATA[MBTI]]></category>
		<category><![CDATA[study]]></category>
		<category><![CDATA[가장 가까운 세 사람의 심리적 거리]]></category>
		<category><![CDATA[공부]]></category>
		<category><![CDATA[기초]]></category>
		<category><![CDATA[백준]]></category>
		<category><![CDATA[백준 20529]]></category>
		<category><![CDATA[백준 20529번]]></category>
		<category><![CDATA[브루트 포스]]></category>
		<category><![CDATA[비둘기 집의 원리]]></category>
		<category><![CDATA[비둘기집 원리]]></category>
		<category><![CDATA[비트마스킹]]></category>
		<category><![CDATA[수학]]></category>
		<category><![CDATA[알고리즘]]></category>
		<category><![CDATA[코딩테스트]]></category>
		<category><![CDATA[코테]]></category>
		<guid isPermaLink="false">https://lycos7560.com/?p=36060</guid>

					<description><![CDATA[<p>가장 가까운 세 사람의 심리적 거리 https://www.acmicpc.net/problem/20529 시간 제한 메모리 제한 제출 정답 맞힌 사람 정답 비율 2 초 1536 MB 4043 1550 1185 36.744% 문제 여러분은 요즘 유행하는 심리검사인 MBTI에 대해 들어보았는가? MBTI(Myers-Briggs Type Indicator)는&#160;C.G.Jung의 심리유형론을 근거로 하여 Katharine Cook Briggs와 Isabel Briggs Myers가 보다 쉽고 일상생활에 유용하게 활용할 수 있도록 고안한 자기보고식 성격유형지표이다. [&#8230;]</p>
<p>The post <a href="https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-20529%eb%b2%88-%ea%b0%80%ec%9e%a5-%ea%b0%80%ea%b9%8c%ec%9a%b4-%ec%84%b8-%ec%82%ac%eb%9e%8c%ec%9d%98-%ec%8b%ac%eb%a6%ac%ec%a0%81-%ea%b1%b0%eb%a6%ac-c-baekjoon/36060/">백준 20529번 (가장 가까운 세 사람의 심리적 거리, C++) [BAEKJOON]</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<script async="" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-5698326622209671" crossorigin="anonymous"></script>
<!-- HorizontalAD -->
<ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-5698326622209671" data-ad-slot="6908948342" data-ad-format="auto" data-full-width-responsive="true"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>



<div style="height:62px" aria-hidden="true" class="wp-block-spacer"></div>


				<div class="wp-block-uagb-table-of-contents uagb-toc__align-left uagb-toc__columns-1  uagb-block-b726977e      "
					data-scroll= "1"
					data-offset= "30"
					style=""
				>
				<div class="uagb-toc__wrap">
						<div class="uagb-toc__title">
							목차 테이블						</div>
																						<div class="uagb-toc__list-wrap ">
						<ol class="uagb-toc__list"><li class="uagb-toc__list"><a href="#가장-가까운-세-사람의-심리적-거리" class="uagb-toc-link__trigger">가장 가까운 세 사람의 심리적 거리</a><ul class="uagb-toc__list"><li class="uagb-toc__list"><a href="#출처" class="uagb-toc-link__trigger">출처</a><li class="uagb-toc__list"><li class="uagb-toc__list"><a href="#알고리즘-분류" class="uagb-toc-link__trigger">알고리즘 분류</a><li class="uagb-toc__list"><li class="uagb-toc__list"><a href="#통과된-코드" class="uagb-toc-link__trigger">통과된 코드</a><li class="uagb-toc__list"><li class="uagb-toc__list"><a href="#더-효율적인-코드-비트-마스킹" class="uagb-toc-link__trigger">더 효율적인 코드 (비트 마스킹)</a></ul></ol>					</div>
									</div>
				</div>
			


<div style="height:62px" aria-hidden="true" class="wp-block-spacer"></div>



<h1 class="wp-block-heading">가장 가까운 세 사람의 심리적 거리</h1>



<p><a href="https://www.acmicpc.net/problem/20529" target="_blank" rel="noreferrer noopener">https://www.acmicpc.net/problem/20529</a></p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><th class="has-text-align-left" data-align="left">시간 제한</th><th class="has-text-align-left" data-align="left">메모리 제한</th><th class="has-text-align-left" data-align="left">제출</th><th class="has-text-align-left" data-align="left">정답</th><th class="has-text-align-left" data-align="left">맞힌 사람</th><th class="has-text-align-left" data-align="left">정답 비율</th></tr></thead><tbody><tr><td class="has-text-align-left" data-align="left">2 초</td><td class="has-text-align-left" data-align="left">1536 MB</td><td class="has-text-align-left" data-align="left">4043</td><td class="has-text-align-left" data-align="left">1550</td><td class="has-text-align-left" data-align="left">1185</td><td class="has-text-align-left" data-align="left">36.744%</td></tr></tbody></table></figure>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">문제</h3>



<p>여러분은 요즘 유행하는 심리검사인 MBTI에 대해 들어보았는가?</p>



<p>MBTI(Myers-Briggs Type Indicator)는&nbsp;C.G.Jung의 심리유형론을 근거로 하여 Katharine Cook Briggs와 Isabel Briggs Myers가 보다 쉽고 </p>



<p>일상생활에 유용하게 활용할 수 있도록 고안한 자기보고식 성격유형지표이다. (출처: 위키백과)</p>



<p>MBTI는 아래와 같이 네 가지 척도로 사람들의 성격을 구분한다.</p>



<ul class="wp-block-list">
<li>외향(E) / 내향(I)</li>



<li>감각(S) / 직관(N)</li>



<li>사고(T) / 감정(F)</li>



<li>판단(J) / 인식(P)</li>
</ul>



<p>각 척도마다 두 가지 분류가 존재하므로, MBTI는 총&nbsp;2^4 = 16가지 유형이 있음을 알 수 있다. </p>



<p>일반적으로&nbsp;MBTI의 유형들은 각 분류를 나타내는 알파벳 한 글자씩을 따 네 글자로 표시하게 된다. </p>



<p>모든 유형의 목록은 다음과 같다.</p>



<ul class="wp-block-list">
<li>ISTJ, ISFJ, INFJ, INTJ, ISTP, ISFP, INFP, INTP, ESTP, ESFP, ENFP, ENTP, ESTJ, ESFJ, ENFJ, ENTJ</li>
</ul>



<p>MBTI 성격 유형을 이용하면&nbsp;두 사람 사이의 심리적인 거리를 정의할 수 있다. </p>



<p>이는&nbsp;두 사람의 MBTI 유형에서&nbsp;서로 다른 분류에 속하는 척도의 수로 정의된다. </p>



<p>예를 들어, MBTI 유형이 ISTJ인 사람과 ISFJ인 사람 사이의 거리는 1이며, INTP인 사람과 ENTJ인 사람 사이의 거리는 2이다.</p>



<p>이 정의를 확장해서 세&nbsp;사람 사이의 심리적인 거리도 정의할 수 있다.&nbsp;</p>



<p>세 사람&nbsp;A, B, C가 있을 때 이들의 심리적인 거리는</p>



<p>(A와&nbsp;B&nbsp;사이의 심리적인&nbsp;거리)&nbsp;+ (B와&nbsp;C&nbsp;사이의 심리적인&nbsp;거리)&nbsp;+ (A와&nbsp;C&nbsp;사이의 심리적인&nbsp;거리)로 정의한다.</p>



<p>대학교에서 심리학 교수로&nbsp;일하는 종서는 자신이 가르치는 학생들의 심리적인 특성을 분석하고 싶어한다.</p>



<p>오늘이 생일인 종서를 위해&nbsp;N명의 학생들의 MBTI 유형이 주어질 때, </p>



<p>가장 가까운 세&nbsp;학생 사이의 심리적인 거리를 구해보자.</p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">입력</h3>



<p>첫 줄에는 테스트 케이스의 수를 나타내는 정수&nbsp;T가 주어진다.</p>



<p>각 테스트 케이스의 첫 줄에는 학생의 수를 나타내는 하나의 정수&nbsp;N이 주어지며, </p>



<p>두 번째 줄에는 각 학생의 MBTI 성격 유형을 나타내는 문자열들이 사이에 공백을 두고 주어진다.</p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">출력</h3>



<p>각 테스트 케이스에 대한 답을 정수 형태로 한 줄에 하나씩 출력한다.</p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">제한</h3>



<ul class="wp-block-list">
<li> 1≤ T ≤50 </li>



<li> 3≤ N ≤100000</li>



<li>각 테스트 케이스의 N의 합은 100,000을 넘지 않는다.</li>
</ul>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">예제 입력 1</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">3
3
ENTJ INTP ESFJ
4
ESFP ESFP ESFP ESFP
5
INFP INFP ESTP ESTJ ISTJ</pre>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">예제 출력 1</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">8
0
4</pre>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<ul class="wp-block-list">
<li>첫 번째 테스트 케이스의 경우, ENTJ와 INTP의 심리적인 거리는 2, <br>ENTJ와 ESFJ의 심리적인 거리는 2, INTP와 ESFJ의 심리적인 거리는 4이므로 세 사람의 심리적인 거리는 2+2+4=8이다.</li>



<li>두 번째 테스트 케이스의 경우, 어떤 사람 둘을 골라도 심리적인 거리가 0이므로 가장 가까운 세 사람의 심리적인 거리는 0이다.</li>



<li>세 번째 테스트 케이스의 경우, 심리적인 거리를 최소화하려면 MBTI가 ESTP, ESTJ, ISTJ인 세 사람을 골라야 한다. <br>ESTP와 ESTJ의 심리적인 거리는 1, ESTP와 ISTJ의 심리적인 거리는 2, ESTJ와 ISTJ의 심리적인 거리는 1이므로 세 사람의 심리적인 거리는 1+2+1=4이다.</li>
</ul>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">출처</h2>



<p><a href="https://www.acmicpc.net/category/45" target="_blank" rel="noreferrer noopener">Contest</a> > <a href="https://www.acmicpc.net/category/469" target="_blank" rel="noreferrer noopener">Good Bye, BOJ</a> > <a href="https://www.acmicpc.net/category/detail/2379" target="_blank" rel="noreferrer noopener">Good Bye, BOJ 2020!</a> B번</p>



<ul class="wp-block-list">
<li>문제를 검수한 사람: <a href="https://www.acmicpc.net/user/ahgus89" target="_blank" rel="noreferrer noopener">ahgus89</a>, <a href="https://www.acmicpc.net/user/cgiosy" target="_blank" rel="noreferrer noopener">cgiosy</a>, <a href="https://www.acmicpc.net/user/cheetose" target="_blank" rel="noreferrer noopener">cheetose</a>, <a href="https://www.acmicpc.net/user/cs71107" target="_blank" rel="noreferrer noopener">cs71107</a>, <a href="https://www.acmicpc.net/user/evenharder" target="_blank" rel="noreferrer noopener">evenharder</a>, <a href="https://www.acmicpc.net/user/gravekper" target="_blank" rel="noreferrer noopener">gravekper</a>, <a href="https://www.acmicpc.net/user/jhnah917" target="_blank" rel="noreferrer noopener">jhnah917</a>, <a href="https://www.acmicpc.net/user/junseo" target="_blank" rel="noreferrer noopener">junseo</a>, <a href="https://www.acmicpc.net/user/kdh9949" target="_blank" rel="noreferrer noopener">kdh9949</a>, <a href="https://www.acmicpc.net/user/koosaga">koosaga</a>, <a href="https://www.acmicpc.net/user/queued_q" target="_blank" rel="noreferrer noopener">queued_q</a>, <a href="https://www.acmicpc.net/user/rdd6584" target="_blank" rel="noreferrer noopener">rdd6584</a>, <a href="https://www.acmicpc.net/user/ryute" target="_blank" rel="noreferrer noopener">ryute</a></li>



<li>데이터를 추가한 사람: <a href="https://www.acmicpc.net/user/kimyh0316" target="_blank" rel="noreferrer noopener">kimyh0316</a></li>



<li>문제를 만든 사람: <a href="https://www.acmicpc.net/user/leejseo" target="_blank" rel="noreferrer noopener">leejseo</a>, <a href="https://www.acmicpc.net/user/queued_q" target="_blank" rel="noreferrer noopener">queued_q</a></li>
</ul>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">알고리즘 분류</h2>



<ul class="wp-block-list">
<li><a href="https://www.acmicpc.net/problem/tag/124" target="_blank" rel="noreferrer noopener">수</a><a href="https://www.acmicpc.net/problem/tag/124">학</a></li>



<li><a href="https://www.acmicpc.net/problem/tag/125" target="_blank" rel="noreferrer noopener">브루트포스 알고리즘</a></li>



<li><a href="https://www.acmicpc.net/problem/tag/189" target="_blank" rel="noreferrer noopener">비둘기집 원리</a></li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity is-style-wide" style="margin-top:var(--wp--preset--spacing--80);margin-bottom:var(--wp--preset--spacing--80)"/>



<figure class="wp-block-embed is-type-wp-embed is-provider-어제와-내일의-나-그-사이의-이야기 wp-block-embed-어제와-내일의-나-그-사이의-이야기"><div class="wp-block-embed__wrapper">
<blockquote class="wp-embedded-content" data-secret="8eWN1jIoBu"><a href="https://lycos7560.com/etc/%ec%95%8c%ea%b3%a0%eb%a6%ac%ec%a6%98-%eb%b9%84%eb%91%98%ea%b8%b0-%ec%a7%91%ec%9d%98-%ec%9b%90%eb%a6%ac-pigeonhole-principle/36080/">알고리즘 – 비둘기 집의 원리 (Pigeonhole Principle)</a></blockquote><iframe loading="lazy" class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  title="&#8220;알고리즘 – 비둘기 집의 원리 (Pigeonhole Principle)&#8221; &#8212; 어제와 내일의 나 그 사이의 이야기" src="https://lycos7560.com/etc/%ec%95%8c%ea%b3%a0%eb%a6%ac%ec%a6%98-%eb%b9%84%eb%91%98%ea%b8%b0-%ec%a7%91%ec%9d%98-%ec%9b%90%eb%a6%ac-pigeonhole-principle/36080/embed/#?secret=t2KQIZOfcp#?secret=8eWN1jIoBu" data-secret="8eWN1jIoBu" width="600" height="338" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe>
</div></figure>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading has-large-font-size">통과된 코드</h2>



<p>비둘기 집의 원리를 이용하여 N &gt; 32 인 경우를 처리해주는 것이 문제의 포인트</p>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<pre class="EnlighterJSRAW" data-enlighter-language="cpp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#include &lt;iostream>
#include &lt;vector>
using namespace std;
int _T, _N, _Res = INT32_MAX;
string _Str;
int main()
{
	ios_base::sync_with_stdio(false);
	std::cin.tie(NULL);
	std::cout.tie(NULL);
	cin >> _T;
	for (int i = 0; i &lt; _T; i++) {
		cin >> _N;
		vector&lt;string> _StrV;
		for (int i = 0; i &lt; _N; i++) {
			cin >> _Str;
			_StrV.push_back(_Str);
		}
		if (_N > 32) {
			std::cout &lt;&lt; 0 &lt;&lt; "\n";
			continue;
		}
		int _Sum;
		_Res = INT32_MAX;
		for (int i = 0; i &lt; _N; i++) {
			for (int j = i + 1; j &lt; _N; j++) {
				for (int k = j + 1; k &lt; _N; k++) {
					_Sum = 0;
					for (int q = 0; q &lt; 4; q++) {
						if (_StrV[i][q] != _StrV[j][q]) _Sum++;
						if (_StrV[j][q] != _StrV[k][q]) _Sum++;
						if (_StrV[k][q] != _StrV[i][q]) _Sum++;
					}
					_Res = min(_Res, _Sum);
				}
			}
		}
		std::cout &lt;&lt; _Res &lt;&lt; "\n";
	}

	return 0;
}</pre>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-image size-full"><img decoding="async" width="1061" height="88" src="https://lycos7560.com/wp-content/uploads/2023/07/image-33.png" alt="" class="wp-image-36070" srcset="https://lycos7560.com/wp-content/uploads/2023/07/image-33.png 1061w, https://lycos7560.com/wp-content/uploads/2023/07/image-33-300x25.png 300w, https://lycos7560.com/wp-content/uploads/2023/07/image-33-768x64.png 768w" sizes="(max-width: 1061px) 100vw, 1061px" /></figure>



<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading has-large-font-size">더 효율적인 코드 (비트 마스킹)</h2>



<p>비트마스킹을 이용하여 메모리 및 속도를 개선합니다.</p>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<pre class="EnlighterJSRAW" data-enlighter-language="cpp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#include &lt;iostream>
#include &lt;vector>
using namespace std;
int _T, _N, _Res = INT32_MAX;
vector&lt;int> _bitV;
string _Str;
int main()
{
	ios_base::sync_with_stdio(false);
	std::cin.tie(NULL);
	std::cout.tie(NULL);
	cin >> _T;
	for (int i = 0; i &lt; _T; i++) {
		cin >> _N;
		_bitV.clear();
		for (int i = 0; i &lt; _N; i++) {
			cin >> _Str;
			int _bit = 0;
			if (_Str[0] == 'I') _bit += 1 &lt;&lt; 0;
			if (_Str[1] == 'N') _bit += 1 &lt;&lt; 1;
			if (_Str[2] == 'F') _bit += 1 &lt;&lt; 2;
			if (_Str[3] == 'P') _bit += 1 &lt;&lt; 3;
			_bitV.push_back(_bit);
		}
		if (_N > 32) {
			std::cout &lt;&lt; 0 &lt;&lt; "\n";
			continue;
		}
		int _Sum;
		_Res = INT32_MAX;
		for (int i = 0; i &lt; _N; i++) {
			for (int j = i + 1; j &lt; _N; j++) {
				for (int k = j + 1; k &lt; _N; k++) {
					_Sum = 0;
					for (int q = 0; q &lt; 4; q++) {
						if ((_bitV[i] &amp; (1 &lt;&lt; q)) != (_bitV[j] &amp; (1 &lt;&lt; q))) _Sum++;
						if ((_bitV[j] &amp; (1 &lt;&lt; q)) != (_bitV[k] &amp; (1 &lt;&lt; q))) _Sum++;
						if ((_bitV[k] &amp; (1 &lt;&lt; q)) != (_bitV[i] &amp; (1 &lt;&lt; q))) _Sum++;
					}
					_Res = min(_Res, _Sum);
				}
			}
		}
		std::cout &lt;&lt; _Res &lt;&lt; "\n";
	}

	return 0;
}</pre>



<div style="height:50px" aria-hidden="true" class="wp-block-spacer"></div>



<script async="" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-5698326622209671" crossorigin="anonymous"></script>
<ins class="adsbygoogle" style="display:block" data-ad-format="autorelaxed" data-ad-client="ca-pub-5698326622209671" data-ad-slot="4245812909"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
<p>The post <a href="https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-20529%eb%b2%88-%ea%b0%80%ec%9e%a5-%ea%b0%80%ea%b9%8c%ec%9a%b4-%ec%84%b8-%ec%82%ac%eb%9e%8c%ec%9d%98-%ec%8b%ac%eb%a6%ac%ec%a0%81-%ea%b1%b0%eb%a6%ac-c-baekjoon/36060/">백준 20529번 (가장 가까운 세 사람의 심리적 거리, C++) [BAEKJOON]</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-20529%eb%b2%88-%ea%b0%80%ec%9e%a5-%ea%b0%80%ea%b9%8c%ec%9a%b4-%ec%84%b8-%ec%82%ac%eb%9e%8c%ec%9d%98-%ec%8b%ac%eb%a6%ac%ec%a0%81-%ea%b1%b0%eb%a6%ac-c-baekjoon/36060/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>백준 2587번 (대표값2, C++) [BAEKJOON]</title>
		<link>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-2587%eb%b2%88-%eb%8c%80%ed%91%9c%ea%b0%922-c-baekjoon/35752/</link>
					<comments>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-2587%eb%b2%88-%eb%8c%80%ed%91%9c%ea%b0%922-c-baekjoon/35752/#respond</comments>
		
		<dc:creator><![CDATA[lycos7560]]></dc:creator>
		<pubDate>Fri, 07 Jul 2023 21:13:56 +0000</pubDate>
				<category><![CDATA[BaekjoonOnlineJudge]]></category>
		<category><![CDATA[C++/CPP]]></category>
		<category><![CDATA[2587]]></category>
		<category><![CDATA[2587번]]></category>
		<category><![CDATA[Baekjoon]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[cpp]]></category>
		<category><![CDATA[sort]]></category>
		<category><![CDATA[study]]></category>
		<category><![CDATA[공부]]></category>
		<category><![CDATA[구현]]></category>
		<category><![CDATA[기초]]></category>
		<category><![CDATA[대표값2]]></category>
		<category><![CDATA[백준]]></category>
		<category><![CDATA[백준 2587]]></category>
		<category><![CDATA[백준 2587번]]></category>
		<category><![CDATA[사칙연산]]></category>
		<category><![CDATA[선택 정렬]]></category>
		<category><![CDATA[수학]]></category>
		<category><![CDATA[알고리즘]]></category>
		<category><![CDATA[정렬]]></category>
		<category><![CDATA[코딩테스트]]></category>
		<category><![CDATA[코테]]></category>
		<guid isPermaLink="false">https://lycos7560.com/?p=35752</guid>

					<description><![CDATA[<p>백준 2587번 '대표값2' 문제에 대한글입니다.  (This is an article about Baekjoon Number 2587 'Representative Value 2'.)</p>
<p>The post <a href="https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-2587%eb%b2%88-%eb%8c%80%ed%91%9c%ea%b0%922-c-baekjoon/35752/">백준 2587번 (대표값2, C++) [BAEKJOON]</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<script async="" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-5698326622209671" crossorigin="anonymous"></script>
<!-- HorizontalAD -->
<ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-5698326622209671" data-ad-slot="6908948342" data-ad-format="auto" data-full-width-responsive="true"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>



<div style="height:62px" aria-hidden="true" class="wp-block-spacer"></div>


				<div class="wp-block-uagb-table-of-contents uagb-toc__align-left uagb-toc__columns-1  uagb-block-8b0bfb40      "
					data-scroll= "1"
					data-offset= "30"
					style=""
				>
				<div class="uagb-toc__wrap">
						<div class="uagb-toc__title">
							목차 테이블						</div>
																						<div class="uagb-toc__list-wrap ">
						<ol class="uagb-toc__list"><li class="uagb-toc__list"><a href="#대표값2" class="uagb-toc-link__trigger">대표값2</a><ul class="uagb-toc__list"><li class="uagb-toc__list"><a href="#통과된-코드" class="uagb-toc-link__trigger">통과된 코드</a></ul></ol>					</div>
									</div>
				</div>
			


<div style="height:62px" aria-hidden="true" class="wp-block-spacer"></div>



<h1 class="wp-block-heading">대표값2</h1>



<p><a href="https://www.acmicpc.net/problem/2587" target="_blank" rel="noreferrer noopener">https://www.acmicpc.net/problem/2587</a></p>



<div style="height:62px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-table"><table><thead><tr><th>시간 제한</th><th>메모리 제한</th><th>제출</th><th>정답</th><th>맞힌 사람</th><th>정답 비율</th></tr></thead><tbody><tr><td>1 초</td><td>128 MB</td><td>31241</td><td>19249</td><td>17720</td><td>62.379%</td></tr></tbody></table></figure>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">문제</h3>



<p>어떤 수들이 있을 때, 그 수들을 대표하는 값으로 가장 흔하게 쓰이는 것은 평균이다. </p>



<p>평균은 주어진 모든 수의 합을 수의 개수로 나눈 것이다. </p>



<p>예를 들어 10, 40, 30, 60, 30의 평균은 (10 + 40 + 30 + 60 + 30) / 5 = 170 / 5 = 34가 된다.</p>



<p>평균 이외의 또 다른 대표값으로 중앙값이라는 것이 있다. </p>



<p>중앙값은 주어진 수를 크기 순서대로 늘어 놓았을 때 가장 중앙에 놓인 값이다. </p>



<p>예를 들어 10, 40, 30, 60, 30의 경우, 크기 순서대로 늘어 놓으면</p>



<p>10 30 30 40 60</p>



<p>이 되고 따라서 중앙값은 30이 된다.</p>



<p>다섯 개의 자연수가 주어질 때 이들의 평균과 중앙값을 구하는 프로그램을 작성하시오.</p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">입력</h3>



<p>첫째 줄부터 다섯 번째 줄까지 한 줄에 하나씩 자연수가 주어진다. </p>



<p>주어지는 자연수는 100 보다 작은 10의 배수이다.</p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">출력</h3>



<p>첫째 줄에는 평균을 출력하고, 둘째 줄에는 중앙값을 출력한다. </p>



<p>평균과 중앙값은 모두 자연수이다.</p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">예제 입력 1</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">10
40
30
60
30</pre>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">예제 출력 1</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">34
30</pre>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">출처</h3>



<p><a href="https://www.acmicpc.net/category/2" target="_blank" rel="noreferrer noopener">Olympiad</a>&nbsp;&gt;&nbsp;<a href="https://www.acmicpc.net/category/55" target="_blank" rel="noreferrer noopener">한국정보올림피아드</a>&nbsp;&gt;&nbsp;<a href="https://www.acmicpc.net/category/57" target="_blank" rel="noreferrer noopener">한국정보올림피아드시․도지역본선</a>&nbsp;&gt;&nbsp;<a href="https://www.acmicpc.net/category/72" target="_blank" rel="noreferrer noopener">지역본선 2005</a>&nbsp;&gt;&nbsp;<a href="https://www.acmicpc.net/category/detail/373" target="_blank" rel="noreferrer noopener">초등부</a>&nbsp;1번</p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">알고리즘 분류</h3>



<ul class="wp-block-list">
<li><a href="https://www.acmicpc.net/problem/tag/124" target="_blank" rel="noreferrer noopener">수학</a></li>



<li><a href="https://www.acmicpc.net/problem/tag/102" target="_blank" rel="noreferrer noopener">구</a><a href="https://www.acmicpc.net/problem/tag/102">현</a></li>



<li><a href="https://www.acmicpc.net/problem/tag/97">정렬</a></li>



<li><a href="https://www.acmicpc.net/problem/tag/121" target="_blank" rel="noreferrer noopener">사칙연산</a></li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity is-style-wide" style="margin-top:var(--wp--preset--spacing--80);margin-bottom:var(--wp--preset--spacing--80)"/>



<h2 class="wp-block-heading has-large-font-size">통과된 코드</h2>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<pre class="EnlighterJSRAW" data-enlighter-language="cpp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#include &lt;iostream>

using namespace std;

int _Arr[6], _Sum;

int main()
{
	for (int i = 0; i &lt; 5; i++)
		cin >> _Arr[i];
	// 배열의 크기가 작아서 선택 정렬을 사용
	for (int i = 0; i &lt; 5; i++)
		for (int j = 0; j &lt; 5; j++) {
			if (i == j) continue;
			if (_Arr[i] > _Arr[j]) {
				_Arr[5] = _Arr[i];
				_Arr[i] = _Arr[j];
				_Arr[j] = _Arr[5];
			}
		}
	for (int i = 0; i &lt; 5; i++)
		_Sum += _Arr[i];
	cout &lt;&lt; (int)(_Sum / 5) &lt;&lt; "\n";
	cout &lt;&lt; _Arr[2];

	return 0;
}</pre>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-image size-full"><img decoding="async" width="1205" height="99" src="https://lycos7560.com/wp-content/uploads/2023/07/image-15.png" alt="" class="wp-image-35755" srcset="https://lycos7560.com/wp-content/uploads/2023/07/image-15.png 1205w, https://lycos7560.com/wp-content/uploads/2023/07/image-15-300x25.png 300w, https://lycos7560.com/wp-content/uploads/2023/07/image-15-768x63.png 768w" sizes="(max-width: 1205px) 100vw, 1205px" /></figure>



<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>



<script async="" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-5698326622209671" crossorigin="anonymous"></script>
<ins class="adsbygoogle" style="display:block" data-ad-format="autorelaxed" data-ad-client="ca-pub-5698326622209671" data-ad-slot="4245812909"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
<p>The post <a href="https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-2587%eb%b2%88-%eb%8c%80%ed%91%9c%ea%b0%922-c-baekjoon/35752/">백준 2587번 (대표값2, C++) [BAEKJOON]</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-2587%eb%b2%88-%eb%8c%80%ed%91%9c%ea%b0%922-c-baekjoon/35752/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>백준 1026번 (보물, C++) [BAEKJOON]</title>
		<link>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-1026%eb%b2%88-%eb%b3%b4%eb%ac%bc-c-baekjoon/35644/</link>
					<comments>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-1026%eb%b2%88-%eb%b3%b4%eb%ac%bc-c-baekjoon/35644/#respond</comments>
		
		<dc:creator><![CDATA[lycos7560]]></dc:creator>
		<pubDate>Mon, 03 Jul 2023 10:35:42 +0000</pubDate>
				<category><![CDATA[BaekjoonOnlineJudge]]></category>
		<category><![CDATA[C++/CPP]]></category>
		<category><![CDATA[1026]]></category>
		<category><![CDATA[1026번]]></category>
		<category><![CDATA[Baekjoon]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[cpp]]></category>
		<category><![CDATA[study]]></category>
		<category><![CDATA[공부]]></category>
		<category><![CDATA[그리디]]></category>
		<category><![CDATA[그리디 알고리즘]]></category>
		<category><![CDATA[기초]]></category>
		<category><![CDATA[백준]]></category>
		<category><![CDATA[백준 1026]]></category>
		<category><![CDATA[백준 1026번]]></category>
		<category><![CDATA[보물]]></category>
		<category><![CDATA[수학]]></category>
		<category><![CDATA[알고리즘]]></category>
		<category><![CDATA[정렬]]></category>
		<category><![CDATA[코딩테스트]]></category>
		<category><![CDATA[코테]]></category>
		<guid isPermaLink="false">https://lycos7560.com/?p=35644</guid>

					<description><![CDATA[<p>백준 1026번 '보물' 문제에 대한 글입니다. (This article is about the issue of "Treasure" in Baekjoon Number 1026)</p>
<p>The post <a href="https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-1026%eb%b2%88-%eb%b3%b4%eb%ac%bc-c-baekjoon/35644/">백준 1026번 (보물, C++) [BAEKJOON]</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<script async="" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-5698326622209671" crossorigin="anonymous"></script>
<!-- HorizontalAD -->
<ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-5698326622209671" data-ad-slot="6908948342" data-ad-format="auto" data-full-width-responsive="true"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>



<div style="height:62px" aria-hidden="true" class="wp-block-spacer"></div>


				<div class="wp-block-uagb-table-of-contents uagb-toc__align-left uagb-toc__columns-1  uagb-block-bf784e4e      "
					data-scroll= "1"
					data-offset= "30"
					style=""
				>
				<div class="uagb-toc__wrap">
						<div class="uagb-toc__title">
							목차 테이블						</div>
																						<div class="uagb-toc__list-wrap ">
						<ol class="uagb-toc__list"><li class="uagb-toc__list"><a href="#보물" class="uagb-toc-link__trigger">보물</a><ul class="uagb-toc__list"><li class="uagb-toc__list"><a href="#통과된-코드" class="uagb-toc-link__trigger">통과된 코드</a></ul></ol>					</div>
									</div>
				</div>
			


<div style="height:62px" aria-hidden="true" class="wp-block-spacer"></div>



<h1 class="wp-block-heading">보물</h1>



<p><a href="https://www.acmicpc.net/problem/1026" target="_blank" rel="noreferrer noopener">https://www.acmicpc.net/problem/1026</a></p>



<div style="height:62px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><th class="has-text-align-left" data-align="left">시간 제한</th><th class="has-text-align-left" data-align="left">메모리 제한</th><th class="has-text-align-left" data-align="left">제출</th><th class="has-text-align-left" data-align="left">정답</th><th class="has-text-align-left" data-align="left">맞힌 사람</th><th class="has-text-align-left" data-align="left">정답 비율</th></tr></thead><tbody><tr><td class="has-text-align-left" data-align="left">2 초</td><td class="has-text-align-left" data-align="left">128 MB</td><td class="has-text-align-left" data-align="left">52186</td><td class="has-text-align-left" data-align="left">34340</td><td class="has-text-align-left" data-align="left">29166</td><td class="has-text-align-left" data-align="left">68.049%</td></tr></tbody></table></figure>



<div style="height:62px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">문제</h3>



<p>옛날 옛적에 수학이 항상 큰 골칫거리였던 나라가 있었다. </p>



<p>이 나라의 국왕 김지민은 다음과 같은 문제를 내고 큰 상금을 걸었다.</p>



<p>길이가 N인 정수 배열 A와 B가 있다. </p>



<p>다음과 같이 함수 S를 정의하자.</p>



<p>S = A[0] × B[0] + &#8230; + A[N-1] × B[N-1]</p>



<p>S의 값을 가장 작게 만들기 위해 A의 수를 재배열하자. </p>



<p>단, B에 있는 수는 재배열하면 안 된다.</p>



<p>S의 최솟값을 출력하는 프로그램을 작성하시오.</p>



<div style="height:62px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">입력</h3>



<p>첫째 줄에 N이 주어진다. </p>



<p>둘째 줄에는 A에 있는 N개의 수가 순서대로 주어지고, </p>



<p>셋째 줄에는 B에 있는 수가 순서대로 주어진다. </p>



<p>N은 50보다 작거나 같은 자연수이고, </p>



<p>A와 B의 각 원소는 100보다 작거나 같은 음이 아닌 정수이다.</p>



<div style="height:62px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">출력</h3>



<p>첫째 줄에 S의 최솟값을 출력한다.</p>



<div style="height:62px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">예제 입력 1</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">5
1 1 1 6 0
2 7 8 3 1</pre>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">예제 출력 1</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">18</pre>



<div style="height:80px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">예제 입력 2</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">3
1 1 3
10 30 20</pre>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">예제 출력 2</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">80</pre>



<div style="height:80px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">예제 입력 3</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">9
5 15 100 31 39 0 0 3 26
11 12 13 2 3 4 5 9 1</pre>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">예제 출력 3</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">528</pre>



<div style="height:80px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">힌트</h3>



<p>예제 1의 경우 A를 {1, 1, 0, 1, 6}과 같이 재배열하면 된다.</p>



<div style="height:80px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">출처</h3>



<ul class="wp-block-list">
<li>문제를 번역한 사람:&nbsp;<a href="https://www.acmicpc.net/user/baekjoon" target="_blank" rel="noreferrer noopener">baekjoon</a></li>
</ul>



<div style="height:80px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">알고리즘 분류</h3>



<ul class="wp-block-list">
<li><a href="https://www.acmicpc.net/problem/tag/124" target="_blank" rel="noreferrer noopener">수학</a></li>



<li><a href="https://www.acmicpc.net/problem/tag/33" target="_blank" rel="noreferrer noopener">그리디 알고리즘</a></li>



<li><a href="https://www.acmicpc.net/problem/tag/97" target="_blank" rel="noreferrer noopener">정렬</a></li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity is-style-wide" style="margin-top:var(--wp--preset--spacing--80);margin-bottom:var(--wp--preset--spacing--80)"/>



<figure class="wp-block-image size-full is-resized"><img decoding="async" src="https://lycos7560.com/wp-content/uploads/2023/07/image-5.png" alt="" class="wp-image-35652" width="1076" height="752" srcset="https://lycos7560.com/wp-content/uploads/2023/07/image-5.png 1435w, https://lycos7560.com/wp-content/uploads/2023/07/image-5-300x210.png 300w, https://lycos7560.com/wp-content/uploads/2023/07/image-5-768x537.png 768w" sizes="(max-width: 1076px) 100vw, 1076px" /></figure>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading has-large-font-size">통과된 코드</h2>



<p>문제에서 &#8220;단, B에 있는 수는 재배열하면 안 <em>된다.&#8221;라는</em> 문장이 왜 있는지 의문</p>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<pre class="EnlighterJSRAW" data-enlighter-language="cpp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#include &lt;iostream>
#include &lt;algorithm>
using namespace std;
int _N, _Res = 0, _A[50], _B[50];
// 오름차순 정렬
bool Greater(int a, int b)
{
	return a > b;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin >> _N;
	for (int i = 0; i &lt; _N; i++)
		cin >> _A[i];
	for (int i = 0; i &lt; _N; i++)
		cin >> _B[i];
	sort(_A, _A + _N, Greater);
	sort(_B, _B + _N);
	for (int i = 0; i &lt; _N; i++)
		_Res += (_B[i] * _A[i]);
	cout &lt;&lt; _Res;
	return 0;
}</pre>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-image size-full"><img decoding="async" width="1205" height="96" src="https://lycos7560.com/wp-content/uploads/2023/07/image-6.png" alt="" class="wp-image-35653" srcset="https://lycos7560.com/wp-content/uploads/2023/07/image-6.png 1205w, https://lycos7560.com/wp-content/uploads/2023/07/image-6-300x24.png 300w, https://lycos7560.com/wp-content/uploads/2023/07/image-6-768x61.png 768w" sizes="(max-width: 1205px) 100vw, 1205px" /></figure>



<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>



<script async="" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-5698326622209671" crossorigin="anonymous"></script>
<ins class="adsbygoogle" style="display:block" data-ad-format="autorelaxed" data-ad-client="ca-pub-5698326622209671" data-ad-slot="4245812909"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
<p>The post <a href="https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-1026%eb%b2%88-%eb%b3%b4%eb%ac%bc-c-baekjoon/35644/">백준 1026번 (보물, C++) [BAEKJOON]</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-1026%eb%b2%88-%eb%b3%b4%eb%ac%bc-c-baekjoon/35644/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>백준 11005번 (진법 변환 2, C++) [BAEKJOON]</title>
		<link>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-11005%eb%b2%88-%ec%a7%84%eb%b2%95-%eb%b3%80%ed%99%98-2-c-baekjoon/35248/</link>
					<comments>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-11005%eb%b2%88-%ec%a7%84%eb%b2%95-%eb%b3%80%ed%99%98-2-c-baekjoon/35248/#respond</comments>
		
		<dc:creator><![CDATA[lycos7560]]></dc:creator>
		<pubDate>Mon, 29 May 2023 06:06:56 +0000</pubDate>
				<category><![CDATA[BaekjoonOnlineJudge]]></category>
		<category><![CDATA[C++/CPP]]></category>
		<category><![CDATA[11005]]></category>
		<category><![CDATA[11005번]]></category>
		<category><![CDATA[Baekjoon]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[cpp]]></category>
		<category><![CDATA[study]]></category>
		<category><![CDATA[공부]]></category>
		<category><![CDATA[구현]]></category>
		<category><![CDATA[기초]]></category>
		<category><![CDATA[백준]]></category>
		<category><![CDATA[백준 11005]]></category>
		<category><![CDATA[백준 11005번]]></category>
		<category><![CDATA[변환]]></category>
		<category><![CDATA[수학]]></category>
		<category><![CDATA[알고리즘]]></category>
		<category><![CDATA[진법]]></category>
		<category><![CDATA[진법 변환 2]]></category>
		<category><![CDATA[코딩테스트]]></category>
		<category><![CDATA[코테]]></category>
		<guid isPermaLink="false">https://lycos7560.com/?p=35248</guid>

					<description><![CDATA[<p>백준 11005번 'N진법 변환 2' 문제에 대한 글입니다. (This article is about Baekjoon Number 11005 'N base conversion 2' problem.)</p>
<p>The post <a href="https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-11005%eb%b2%88-%ec%a7%84%eb%b2%95-%eb%b3%80%ed%99%98-2-c-baekjoon/35248/">백준 11005번 (진법 변환 2, C++) [BAEKJOON]</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<script async="" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-5698326622209671" crossorigin="anonymous"></script>
<!-- HorizontalAD -->
<ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-5698326622209671" data-ad-slot="6908948342" data-ad-format="auto" data-full-width-responsive="true"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>



<div style="height:62px" aria-hidden="true" class="wp-block-spacer"></div>


				<div class="wp-block-uagb-table-of-contents uagb-toc__align-left uagb-toc__columns-1  uagb-block-cf12babd      "
					data-scroll= "1"
					data-offset= "30"
					style=""
				>
				<div class="uagb-toc__wrap">
						<div class="uagb-toc__title">
							목차 테이블						</div>
																						<div class="uagb-toc__list-wrap ">
						<ol class="uagb-toc__list"><li class="uagb-toc__list"><a href="#진법-변환-2" class="uagb-toc-link__trigger">진법 변환 2</a><ul class="uagb-toc__list"><li class="uagb-toc__list"><a href="#통과된-코드" class="uagb-toc-link__trigger">통과된 코드</a></ul></ol>					</div>
									</div>
				</div>
			


<div style="height:62px" aria-hidden="true" class="wp-block-spacer"></div>



<h1 class="wp-block-heading">진법 변환 2</h1>



<p class="has-medium-font-size"><a href="https://www.acmicpc.net/problem/11005" target="_blank" rel="noreferrer noopener">https://www.acmicpc.net/problem/11005</a></p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><th class="has-text-align-left" data-align="left">시간 제한</th><th class="has-text-align-left" data-align="left">메모리 제한</th><th class="has-text-align-left" data-align="left">제출</th><th class="has-text-align-left" data-align="left">정답</th><th class="has-text-align-left" data-align="left">맞힌 사람</th><th class="has-text-align-left" data-align="left">정답 비율</th></tr></thead><tbody><tr><td class="has-text-align-left" data-align="left">0.5 초 (추가 시간 없음)</td><td class="has-text-align-left" data-align="left">256 MB</td><td class="has-text-align-left" data-align="left">21982</td><td class="has-text-align-left" data-align="left">11017</td><td class="has-text-align-left" data-align="left">9313</td><td class="has-text-align-left" data-align="left">50.529%</td></tr></tbody></table></figure>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">문제</h3>



<p class="has-medium-font-size">10진법 수 N이 주어진다. </p>



<p class="has-medium-font-size">이 수를 B진법으로 바꿔 출력하는 프로그램을 작성하시오.</p>



<p class="has-medium-font-size">10진법을 넘어가는 진법은 숫자로 표시할 수 없는 자리가 있다. </p>



<p class="has-medium-font-size">이런 경우에는 다음과 같이 알파벳 대문자를 사용한다.</p>



<p class="has-medium-font-size">A: 10, B: 11, &#8230;, F: 15, &#8230;, Y: 34, Z: 35</p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">입력</h3>



<p class="has-medium-font-size">첫째 줄에 N과 B가 주어진다. (2 ≤ B ≤ 36) </p>



<p class="has-medium-font-size">N은 10억보다 작거나 같은 자연수이다.</p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">출력</h3>



<p class="has-medium-font-size">첫째 줄에 10진법 수 N을 B진법으로 출력한다.</p>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">예제 입력 1</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">60466175 36</pre>



<div style="height:31px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">예제 출력 1</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="raw" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">ZZZZZ</pre>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">출처</h3>



<ul class="wp-block-list">
<li>문제를 만든 사람:&nbsp;<a href="https://www.acmicpc.net/user/baekjoon" target="_blank" rel="noreferrer noopener">baekjoon</a></li>



<li>데이터를 추가한 사람:&nbsp;<a href="https://www.acmicpc.net/user/du9172" target="_blank" rel="noreferrer noopener">du9172</a></li>



<li>문제의 오타를 찾은 사람:&nbsp;<a href="https://www.acmicpc.net/user/zmtn94" target="_blank" rel="noreferrer noopener">zmtn94</a></li>
</ul>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<h3 class="wp-block-heading has-large-font-size">알고리즘 분류</h3>



<ul class="wp-block-list">
<li><a href="https://www.acmicpc.net/problem/tag/124" target="_blank" rel="noreferrer noopener">수학</a></li>



<li><a href="https://www.acmicpc.net/problem/tag/102" target="_blank" rel="noreferrer noopener">구현</a></li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity is-style-wide" style="margin-top:var(--wp--preset--spacing--80);margin-bottom:var(--wp--preset--spacing--80)"/>



<h2 class="wp-block-heading has-large-font-size">통과된 코드</h2>



<div style="height:20px" aria-hidden="true" class="wp-block-spacer"></div>



<pre class="EnlighterJSRAW" data-enlighter-language="cpp" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="false" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#include &lt;iostream>
#include &lt;algorithm>
using namespace std;

string DecimalToN(int decimalNum, int n) { // N진수로 변환
    if (decimalNum == 0) return "0";
    string str;
    while (decimalNum != 0) {
        int remainder = decimalNum % n;
        if (remainder &lt; 10) str.push_back(remainder + 48); // 숫자
        else str.push_back(remainder + 55); // 알파벳
        decimalNum /= n;
    }
    reverse(str.begin(), str.end()); // 뒤집기
    return str;
}

int main()
{
    int _N, _D;
    cin >> _N >> _D;
    cout &lt;&lt; DecimalToN(_N, _D);
}</pre>



<div style="height:50px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-image size-full"><img decoding="async" width="1061" height="87" src="https://lycos7560.com/wp-content/uploads/2023/05/image-159.png" alt="" class="wp-image-35249" srcset="https://lycos7560.com/wp-content/uploads/2023/05/image-159.png 1061w, https://lycos7560.com/wp-content/uploads/2023/05/image-159-300x25.png 300w, https://lycos7560.com/wp-content/uploads/2023/05/image-159-768x63.png 768w" sizes="(max-width: 1061px) 100vw, 1061px" /></figure>



<div style="height:40px" aria-hidden="true" class="wp-block-spacer"></div>



<script async="" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-5698326622209671" crossorigin="anonymous"></script>
<ins class="adsbygoogle" style="display:block" data-ad-format="autorelaxed" data-ad-client="ca-pub-5698326622209671" data-ad-slot="4245812909"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>



<p></p>
<p>The post <a href="https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-11005%eb%b2%88-%ec%a7%84%eb%b2%95-%eb%b3%80%ed%99%98-2-c-baekjoon/35248/">백준 11005번 (진법 변환 2, C++) [BAEKJOON]</a> appeared first on <a href="https://lycos7560.com">어제와 내일의 나 그 사이의 이야기</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://lycos7560.com/cpp/baekjoon_online_judge/%eb%b0%b1%ec%a4%80-11005%eb%b2%88-%ec%a7%84%eb%b2%95-%eb%b3%80%ed%99%98-2-c-baekjoon/35248/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
