Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
30 lines (29 sloc) 33.8 KB
---
layout : article
title: "[백준] 2309번 C/C++ 풀이 _ 일곱 난쟁이"
aside:
toc: true
tags: Algorithm
category : Algorithm
author: melonicedlatte
published : True
hellogohn_num : 227
key : 2018-02-23-024610
---
<p>출처:&nbsp;<a href="https://www.acmicpc.net/problem/2309">https://www.acmicpc.net/problem/2309</a>&nbsp;</p><div class="col-md-10" style="width: 975px; color: rgb(51, 51, 51); font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;Apple SD Gothic Neo&quot;, &quot;Noto Sans CJK KR&quot;, &quot;Noto Sans KR&quot;, 나눔바른고딕, 나눔고딕, NanumGothic, 맑은고딕, &quot;Malgun Gothic&quot;, &quot;Nanum Gothic&quot;, sans-serif; font-size: 13px; border-radius: 0px !important;"><div class="page-header" style="border-radius: 0px !important;"><h1 style="margin-top: 5px; font-size: 28px; font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;Apple SD Gothic Neo&quot;, &quot;Noto Sans CJK KR&quot;, &quot;Noto Sans KR&quot;, 나눔바른고딕, 나눔고딕, NanumGothic, 맑은고딕, &quot;Malgun Gothic&quot;, &quot;Nanum Gothic&quot;, sans-serif; font-weight: normal; line-height: 35px; color: rgb(88, 95, 105); text-shadow: none; border-radius: 0px !important;"><span id="problem_title" class="" style="border-radius: 0px !important;">일곱 난쟁이</span>&nbsp;<span class="label label-success" style="padding: 4px 7px; font-size: 11px; font-weight: 400;">성공</span>&nbsp;<span class="label label-info" style="padding: 4px 7px; font-size: 11px; font-weight: 400;">스페셜 저지</span>&nbsp;<span class="label label-light-green" style="padding: 4px 7px; font-size: 11px; font-weight: 400; background: rgb(121, 213, 179);">풀이</span></h1></div></div><div class="col-md-2 no-print" style="width: 195px; color: rgb(51, 51, 51); font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;Apple SD Gothic Neo&quot;, &quot;Noto Sans CJK KR&quot;, &quot;Noto Sans KR&quot;, 나눔바른고딕, 나눔고딕, NanumGothic, 맑은고딕, &quot;Malgun Gothic&quot;, &quot;Nanum Gothic&quot;, sans-serif; font-size: 13px; border-radius: 0px !important;"><div class="btn-group" style="margin-top: 50px; border-radius: 0px !important;"><button class="btn btn-default" type="button" id="favorite_button" data-favorite="0" style="border-top-left-radius: 4px; border-bottom-left-radius: 4px; font-weight: 400; line-height: 1.42857; font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;Apple SD Gothic Neo&quot;, &quot;Noto Sans CJK KR&quot;, &quot;Noto Sans KR&quot;, 나눔바른고딕, 나눔고딕, NanumGothic, 맑은고딕, &quot;Malgun Gothic&quot;, &quot;Nanum Gothic&quot;, sans-serif; text-transform: none; padding: 6px 12px; box-shadow: none; outline: 0px !important;"><span class="glyphicon glyphicon-star-empty" id="favorite_image" style="border-radius: 0px !important;"></span></button><button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" href="#" style="border-top-right-radius: 4px; border-bottom-right-radius: 4px; font-weight: 400; line-height: 1.42857; font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;Apple SD Gothic Neo&quot;, &quot;Noto Sans CJK KR&quot;, &quot;Noto Sans KR&quot;, 나눔바른고딕, 나눔고딕, NanumGothic, 맑은고딕, &quot;Malgun Gothic&quot;, &quot;Nanum Gothic&quot;, sans-serif; text-transform: none; padding-top: 6px; padding-bottom: 6px; box-shadow: none; outline: 0px !important;">문제집&nbsp;<span class="caret" style="border-top-style: solid; border-radius: 0px !important;"></span></button></div></div><div class="col-md-12" style="width: 1170px; color: rgb(51, 51, 51); font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;Apple SD Gothic Neo&quot;, &quot;Noto Sans CJK KR&quot;, &quot;Noto Sans KR&quot;, 나눔바른고딕, 나눔고딕, NanumGothic, 맑은고딕, &quot;Malgun Gothic&quot;, &quot;Nanum Gothic&quot;, sans-serif; font-size: 13px; border-radius: 0px !important;"><div class="table-responsive" style="border-radius: 0px !important;"><table class="table" id="problem-info" style="width: 1140px; border-radius: 0px !important;"><thead style="border-radius: 0px !important;"><tr style="border-radius: 0px !important;"><th style="line-height: 1.42857; border-bottom: none; width: 183.2px; border-radius: 0px !important;">시간 제한</th><th style="line-height: 1.42857; border-bottom: none; width: 182.4px; border-radius: 0px !important;">메모리 제한</th><th style="line-height: 1.42857; border-bottom: none; width: 193.6px; border-radius: 0px !important;">제출</th><th style="line-height: 1.42857; border-bottom: none; width: 193.6px; border-radius: 0px !important;">정답</th><th style="line-height: 1.42857; border-bottom: none; width: 193.6px; border-radius: 0px !important;">맞은 사람</th><th style="line-height: 1.42857; border-bottom: none; width: 193.6px; border-radius: 0px !important;">정답 비율</th></tr></thead><tbody style="border-radius: 0px !important;"><tr style="border-radius: 0px !important;"><td style="line-height: 1.42857; border-radius: 0px !important;">2 초</td><td style="line-height: 1.42857; border-radius: 0px !important;">128 MB</td><td style="line-height: 1.42857; border-radius: 0px !important;">10386</td><td style="line-height: 1.42857; border-radius: 0px !important;">5803</td><td style="line-height: 1.42857; border-radius: 0px !important;">4548</td><td style="line-height: 1.42857; border-radius: 0px !important;">57.157%</td></tr></tbody></table></div></div><div id="problem-body" style="color: rgb(51, 51, 51); font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;Apple SD Gothic Neo&quot;, &quot;Noto Sans CJK KR&quot;, &quot;Noto Sans KR&quot;, 나눔바른고딕, 나눔고딕, NanumGothic, 맑은고딕, &quot;Malgun Gothic&quot;, &quot;Nanum Gothic&quot;, sans-serif; font-size: 13px; border-radius: 0px !important;"><div class="col-md-12" style="width: 1170px; border-radius: 0px !important;"><section id="description" style="border-radius: 0px !important;"><div class="headline" style="margin: 10px 0px 25px; border-bottom: 1px dotted rgb(228, 233, 240); border-radius: 0px !important;"><h2 style="font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;Apple SD Gothic Neo&quot;, &quot;Noto Sans CJK KR&quot;, &quot;Noto Sans KR&quot;, 나눔바른고딕, 나눔고딕, NanumGothic, 맑은고딕, &quot;Malgun Gothic&quot;, &quot;Nanum Gothic&quot;, sans-serif; font-weight: normal; line-height: 33px; color: rgb(88, 95, 105); margin: 0px 0px -2px; font-size: 22px; text-shadow: none; padding-bottom: 5px; display: inline-block; border-bottom: 2px solid rgb(0, 118, 192); border-radius: 0px !important;">문제</h2></div><div id="problem_description" style="font-size: medium; line-height: 30px; border-radius: 0px !important;"><p style="margin-top: 0px; margin-bottom: 10px; color: rgb(85, 85, 85); border-radius: 0px !important;">왕비를 피해 일곱 난쟁이들과 함께 평화롭게 생활하고 있던 백설공주에게 위기가 찾아왔다. 일과를 마치고 돌아온 난쟁이가 일곱 명이 아닌 아홉 명이었던 것이다.</p><p style="margin-top: 0px; margin-bottom: 10px; color: rgb(85, 85, 85); border-radius: 0px !important;">아홉 명의 난쟁이는 모두 자신이 "백설 공주와 일곱 난쟁이"의 주인공이라고 주장했다. 뛰어난 수학적 직관력을 가지고 있던 백설공주는, 다행스럽게도 일곱 난쟁이의 키의 합이 100이 됨을 기억해 냈다.</p><p style="margin-top: 0px; margin-bottom: 10px; color: rgb(85, 85, 85); border-radius: 0px !important;">아홉 난쟁이의 키가 주어졌을 때, 백설공주를 도와 일곱 난쟁이를 찾는 프로그램을 작성하시오.</p></div></section></div><div class="col-md-12" style="width: 1170px; border-radius: 0px !important;"><section id="input" style="border-radius: 0px !important;"><div class="headline" style="margin: 10px 0px 25px; border-bottom: 1px dotted rgb(228, 233, 240); border-radius: 0px !important;"><h2 style="font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;Apple SD Gothic Neo&quot;, &quot;Noto Sans CJK KR&quot;, &quot;Noto Sans KR&quot;, 나눔바른고딕, 나눔고딕, NanumGothic, 맑은고딕, &quot;Malgun Gothic&quot;, &quot;Nanum Gothic&quot;, sans-serif; font-weight: normal; line-height: 33px; color: rgb(88, 95, 105); margin: 0px 0px -2px; font-size: 22px; text-shadow: none; padding-bottom: 5px; display: inline-block; border-bottom: 2px solid rgb(0, 118, 192); border-radius: 0px !important;">입력</h2></div><div id="problem_input" style="font-size: medium; line-height: 30px; border-radius: 0px !important;"><p style="margin-top: 0px; margin-bottom: 10px; color: rgb(85, 85, 85); border-radius: 0px !important;">아홉 개의 줄에 걸쳐 일곱 난쟁이의 키가 주어진다. 주어지는 키는 100을 넘지 않는 자연수이며, 아홉 난쟁이의 키는 모두 다르며, 가능한 정답이 여러가지인 경우에는 아무거나 출력한다.</p></div></section></div><div class="col-md-12" style="width: 1170px; border-radius: 0px !important;"><section id="output" style="border-radius: 0px !important;"><div class="headline" style="margin: 10px 0px 25px; border-bottom: 1px dotted rgb(228, 233, 240); border-radius: 0px !important;"><h2 style="font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;Apple SD Gothic Neo&quot;, &quot;Noto Sans CJK KR&quot;, &quot;Noto Sans KR&quot;, 나눔바른고딕, 나눔고딕, NanumGothic, 맑은고딕, &quot;Malgun Gothic&quot;, &quot;Nanum Gothic&quot;, sans-serif; font-weight: normal; line-height: 33px; color: rgb(88, 95, 105); margin: 0px 0px -2px; font-size: 22px; text-shadow: none; padding-bottom: 5px; display: inline-block; border-bottom: 2px solid rgb(0, 118, 192); border-radius: 0px !important;">출력</h2></div><div id="problem_output" style="font-size: medium; line-height: 30px; border-radius: 0px !important;"><p style="margin-top: 0px; margin-bottom: 10px; color: rgb(85, 85, 85); border-radius: 0px !important;">일곱 난쟁이의 키를 오름차순으로 출력한다.</p></div></section></div><div class="col-md-12" style="width: 1170px; border-radius: 0px !important;"><div class="row" style="border-radius: 0px !important;"><div class="col-md-6" style="width: 585px; border-radius: 0px !important;"><section id="sampleinput" style="border-radius: 0px !important;"><div class="headline" style="margin: 10px 0px 25px; border-bottom: 1px dotted rgb(228, 233, 240); border-radius: 0px !important;"><h2 style="font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;Apple SD Gothic Neo&quot;, &quot;Noto Sans CJK KR&quot;, &quot;Noto Sans KR&quot;, 나눔바른고딕, 나눔고딕, NanumGothic, 맑은고딕, &quot;Malgun Gothic&quot;, &quot;Nanum Gothic&quot;, sans-serif; font-weight: normal; line-height: 33px; color: rgb(88, 95, 105); margin: 0px 0px -2px; font-size: 22px; text-shadow: none; padding-bottom: 5px; display: inline-block; border-bottom: 2px solid rgb(0, 118, 192); border-radius: 0px !important;">예제 입력&nbsp;<button type="button" class="btn btn-link copy-button no-print" data-clipboard-target="#sample-input-1" style="font-weight: 400; line-height: 1.42857; font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;Apple SD Gothic Neo&quot;, &quot;Noto Sans CJK KR&quot;, &quot;Noto Sans KR&quot;, 나눔바른고딕, 나눔고딕, NanumGothic, 맑은고딕, &quot;Malgun Gothic&quot;, &quot;Nanum Gothic&quot;, sans-serif; color: rgb(66, 139, 202); text-transform: none; padding: 0px; outline: 0px !important;">복사</button></h2></div><pre class="sampledata" id="sample-input-1" style="border-radius: 5px; overflow-x: scroll; font-family: Menlo, Monaco, &quot;Source Code Pro&quot;, consolas, monospace; font-size: 18px; padding: 8px; line-height: 1.42857; word-break: normal; word-wrap: normal; background-color: rgb(247, 247, 249); border-color: rgb(225, 225, 232);">20
7
23
19
10
15
25
8
13
</pre></section></div><div class="col-md-6" style="width: 585px; border-radius: 0px !important;"><section id="sampleoutput" style="border-radius: 0px !important;"><div class="headline" style="margin: 10px 0px 25px; border-bottom: 1px dotted rgb(228, 233, 240); border-radius: 0px !important;"><h2 style="font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;Apple SD Gothic Neo&quot;, &quot;Noto Sans CJK KR&quot;, &quot;Noto Sans KR&quot;, 나눔바른고딕, 나눔고딕, NanumGothic, 맑은고딕, &quot;Malgun Gothic&quot;, &quot;Nanum Gothic&quot;, sans-serif; font-weight: normal; line-height: 33px; color: rgb(88, 95, 105); margin: 0px 0px -2px; font-size: 22px; text-shadow: none; padding-bottom: 5px; display: inline-block; border-bottom: 2px solid rgb(0, 118, 192); border-radius: 0px !important;">예제 출력&nbsp;<button type="button" class="btn btn-link copy-button no-print" data-clipboard-target="#sample-output-1" style="font-weight: 400; line-height: 1.42857; font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;Apple SD Gothic Neo&quot;, &quot;Noto Sans CJK KR&quot;, &quot;Noto Sans KR&quot;, 나눔바른고딕, 나눔고딕, NanumGothic, 맑은고딕, &quot;Malgun Gothic&quot;, &quot;Nanum Gothic&quot;, sans-serif; color: rgb(66, 139, 202); text-transform: none; padding: 0px; outline: 0px !important;">복사</button></h2></div><pre class="sampledata" id="sample-output-1" style="border-radius: 5px; overflow-x: scroll; font-family: Menlo, Monaco, &quot;Source Code Pro&quot;, consolas, monospace; font-size: 18px; padding: 8px; line-height: 1.42857; word-break: normal; word-wrap: normal; background-color: rgb(247, 247, 249); border-color: rgb(225, 225, 232);">7
8
10
13
19
20
23
</pre></section></div></div></div><div class="col-md-12" style="width: 1170px; border-radius: 0px !important;"><section id="hint" style="border-radius: 0px !important;"><div class="headline" style="margin: 10px 0px 25px; border-bottom: 1px dotted rgb(228, 233, 240); border-radius: 0px !important;"><h2 style="font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;Apple SD Gothic Neo&quot;, &quot;Noto Sans CJK KR&quot;, &quot;Noto Sans KR&quot;, 나눔바른고딕, 나눔고딕, NanumGothic, 맑은고딕, &quot;Malgun Gothic&quot;, &quot;Nanum Gothic&quot;, sans-serif; font-weight: normal; line-height: 33px; color: rgb(88, 95, 105); margin: 0px 0px -2px; font-size: 22px; text-shadow: none; padding-bottom: 5px; display: inline-block; border-bottom: 2px solid rgb(0, 118, 192); border-radius: 0px !important;">힌트</h2></div><div id="problem_hint" style="font-size: medium; line-height: 30px; border-radius: 0px !important;"></div></section></div></div><div class="col-md-12" style="width: 1170px; color: rgb(51, 51, 51); font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;Apple SD Gothic Neo&quot;, &quot;Noto Sans CJK KR&quot;, &quot;Noto Sans KR&quot;, 나눔바른고딕, 나눔고딕, NanumGothic, 맑은고딕, &quot;Malgun Gothic&quot;, &quot;Nanum Gothic&quot;, sans-serif; font-size: 13px; border-radius: 0px !important;"><section id="source" style="border-radius: 0px !important;"><div class="headline" style="margin: 10px 0px 25px; border-bottom: 1px dotted rgb(228, 233, 240); border-radius: 0px !important;"><h2 style="font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;Apple SD Gothic Neo&quot;, &quot;Noto Sans CJK KR&quot;, &quot;Noto Sans KR&quot;, 나눔바른고딕, 나눔고딕, NanumGothic, 맑은고딕, &quot;Malgun Gothic&quot;, &quot;Nanum Gothic&quot;, sans-serif; font-weight: normal; line-height: 33px; color: rgb(88, 95, 105); margin: 0px 0px -2px; font-size: 22px; text-shadow: none; padding-bottom: 5px; display: inline-block; border-bottom: 2px solid rgb(0, 118, 192); border-radius: 0px !important;">출처</h2></div><p style="margin-top: 0px; margin-bottom: 10px; color: rgb(85, 85, 85); border-radius: 0px !important;"><a href="https://www.acmicpc.net/category/2" style="background-image: initial; background-position: 0px 0px; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; color: rgb(0, 118, 192); text-decoration-line: none; border-radius: 0px !important; outline: 0px !important;">Olympiad&nbsp;</a>&gt;&nbsp;<a href="https://www.acmicpc.net/category/57" style="background-image: initial; background-position: 0px 0px; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; color: rgb(0, 118, 192); text-decoration-line: none; border-radius: 0px !important; outline: 0px !important;">한국정보올림피아드시․도지역본선&nbsp;</a>&gt;&nbsp;<a href="https://www.acmicpc.net/category/74" style="background-image: initial; background-position: 0px 0px; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; color: rgb(0, 118, 192); text-decoration-line: none; border-radius: 0px !important; outline: 0px !important;">지역본선 2004&nbsp;</a>&gt;&nbsp;<a href="https://www.acmicpc.net/category/detail/379" style="background-image: initial; background-position: 0px 0px; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; color: rgb(0, 118, 192); text-decoration-line: none; border-radius: 0px !important; outline: 0px !important;">초등부</a>&nbsp;1번</p></section></div><div class="col-md-12" style="width: 1170px; color: rgb(51, 51, 51); font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;Apple SD Gothic Neo&quot;, &quot;Noto Sans CJK KR&quot;, &quot;Noto Sans KR&quot;, 나눔바른고딕, 나눔고딕, NanumGothic, 맑은고딕, &quot;Malgun Gothic&quot;, &quot;Nanum Gothic&quot;, sans-serif; font-size: 13px; border-radius: 0px !important;"><section id="problem_tags" style="border-radius: 0px !important;"><div class="headline" style="margin: 10px 0px 25px; border-bottom: 1px dotted rgb(228, 233, 240); border-radius: 0px !important;"><h2 style="font-family: &quot;Open Sans&quot;, &quot;Helvetica Neue&quot;, Helvetica, Arial, &quot;Apple SD Gothic Neo&quot;, &quot;Noto Sans CJK KR&quot;, &quot;Noto Sans KR&quot;, 나눔바른고딕, 나눔고딕, NanumGothic, 맑은고딕, &quot;Malgun Gothic&quot;, &quot;Nanum Gothic&quot;, sans-serif; font-weight: normal; line-height: 33px; color: rgb(88, 95, 105); margin: 0px 0px -2px; font-size: 22px; text-shadow: none; padding-bottom: 5px; display: inline-block; border-bottom: 2px solid rgb(0, 118, 192); border-radius: 0px !important;">알고리즘 분류</h2></div><ul class="spoiler-list" style="border-radius: 0px !important;"><li style="color: rgb(85, 85, 85); border-radius: 0px !important;"><a href="https://www.acmicpc.net/problem/tag/%EB%B8%8C%EB%A3%A8%ED%8A%B8%20%ED%8F%AC%EC%8A%A4" class="spoiler-link" style="background-image: initial; background-position: 0px 0px; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial; color: rgb(85, 85, 85); border-radius: 0px !important; outline: 0px !important;">브루트 포스</a></li></ul></section></div><p>&gt;&gt; 풀이 방법</p><p>경우의 수가 워낙 작기도 하고, 별 다른 방법은 보이지 않는다.&nbsp;<br>생각 없이 그냥 전부 탐색하는 것이 가장 빠른 방법이다.&nbsp;<br>여러가지 답 중에 하나만 맞으면 되기 때문에, 맞는 순간 탐색을 종료하면 된다.&nbsp;<br></p><p><br>&gt;&gt; 소스코드&nbsp;</p><div class="colorscripter-code" style="color:#010101; font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace !important; position:relative !important; overflow:auto"><table class="colorscripter-code-table" style="margin:0; padding:0; border:none; background-color:#fafafa; border-radius:4px;" cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:6px; border-right:2px solid #e5e5e5"><div style="margin: 0px; padding: 0px; word-break: normal; text-align: right; color: rgb(102, 102, 102); line-height: 130%;"><div style="line-height:130%">1</div><div style="line-height:130%">2</div><div style="line-height:130%">3</div><div style="line-height:130%">4</div><div style="line-height:130%">5</div><div style="line-height:130%">6</div><div style="line-height:130%">7</div><div style="line-height:130%">8</div><div style="line-height:130%">9</div><div style="line-height:130%">10</div><div style="line-height:130%">11</div><div style="line-height:130%">12</div><div style="line-height:130%">13</div><div style="line-height:130%">14</div><div style="line-height:130%">15</div><div style="line-height:130%">16</div><div style="line-height:130%">17</div><div style="line-height:130%">18</div><div style="line-height:130%">19</div><div style="line-height:130%">20</div><div style="line-height:130%">21</div><div style="line-height:130%">22</div><div style="line-height:130%">23</div><div style="line-height:130%">24</div><div style="line-height:130%">25</div><div style="line-height:130%">26</div><div style="line-height:130%">27</div><div style="line-height:130%">28</div><div style="line-height:130%">29</div><div style="line-height:130%">30</div><div style="line-height:130%">31</div><div style="line-height:130%">32</div><div style="line-height:130%">33</div><div style="line-height:130%">34</div><div style="line-height:130%">35</div><div style="line-height:130%">36</div><div style="line-height:130%">37</div><div style="line-height:130%">38</div><div style="line-height:130%">39</div></div></td><td style="padding-top: 6px; padding-bottom: 6px;"><div style="margin: 0px; padding: 0px; line-height: 130%;"><div style="padding:0 6px; white-space:pre; line-height:130%"><span style="color:#0086b3">#include</span>&nbsp;<span style="color:#ff3399"></span><span style="color:#a71d5d">&lt;</span>iostream<span style="color:#ff3399"></span><span style="color:#a71d5d">&gt;</span></div><div style="background-color:#f0f0f0; padding:0 6px; white-space:pre; line-height:130%"><span style="color:#0086b3">#include</span>&nbsp;<span style="color:#ff3399"></span><span style="color:#a71d5d">&lt;</span><span style="color:#066de2">vector</span><span style="color:#a71d5d">&gt;</span></div><div style="padding:0 6px; white-space:pre; line-height:130%"><span style="color:#0086b3">#include</span>&nbsp;<span style="color:#ff3399"></span><span style="color:#a71d5d">&lt;</span>algorithm<span style="color:#ff3399"></span><span style="color:#a71d5d">&gt;</span></div><div style="background-color:#f0f0f0; padding:0 6px; white-space:pre; line-height:130%"><span style="color:#a71d5d">using</span>&nbsp;<span style="color:#a71d5d">namespace</span>&nbsp;<span style="color:#066de2">std</span>;&nbsp;</div><div style="padding:0 6px; white-space:pre; line-height:130%">&nbsp;</div><div style="background-color:#f0f0f0; padding:0 6px; white-space:pre; line-height:130%"><span style="color:#066de2">int</span>&nbsp;main()&nbsp;{</div><div style="padding:0 6px; white-space:pre; line-height:130%">&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#999999">//&nbsp;초기값&nbsp;받아오기&nbsp;</span></div><div style="background-color:#f0f0f0; padding:0 6px; white-space:pre; line-height:130%">&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#066de2">vector</span><span style="color:#a71d5d">&lt;</span><span style="color:#066de2">int</span><span style="color:#a71d5d">&gt;</span>&nbsp;small_people;</div><div style="padding:0 6px; white-space:pre; line-height:130%">&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#066de2">vector</span><span style="color:#a71d5d">&lt;</span><span style="color:#066de2">int</span><span style="color:#a71d5d">&gt;</span>&nbsp;answer_vec;</div><div style="background-color:#f0f0f0; padding:0 6px; white-space:pre; line-height:130%">&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#a71d5d">for</span>&nbsp;(<span style="color:#066de2">int</span>&nbsp;i&nbsp;<span style="color:#ff3399"></span><span style="color:#a71d5d">=</span>&nbsp;<span style="color:#0099cc">0</span>;&nbsp;i&nbsp;<span style="color:#ff3399"></span><span style="color:#a71d5d">&lt;</span>&nbsp;<span style="color:#0099cc">9</span>;&nbsp;i<span style="color:#ff3399"></span><span style="color:#a71d5d">+</span><span style="color:#ff3399"></span><span style="color:#a71d5d">+</span>)&nbsp;{</div><div style="padding:0 6px; white-space:pre; line-height:130%">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#066de2">int</span>&nbsp;sub;</div><div style="background-color:#f0f0f0; padding:0 6px; white-space:pre; line-height:130%">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#066de2">cin</span>&nbsp;<span style="color:#ff3399"></span><span style="color:#a71d5d">&gt;</span><span style="color:#ff3399"></span><span style="color:#a71d5d">&gt;</span>&nbsp;sub;</div><div style="padding:0 6px; white-space:pre; line-height:130%">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;small_people.<span style="color:#066de2">push_back</span>(sub);</div><div style="background-color:#f0f0f0; padding:0 6px; white-space:pre; line-height:130%">&nbsp;&nbsp;&nbsp;&nbsp;}</div><div style="padding:0 6px; white-space:pre; line-height:130%">&nbsp;</div><div style="background-color:#f0f0f0; padding:0 6px; white-space:pre; line-height:130%">&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#066de2">int</span>&nbsp;isComplete&nbsp;<span style="color:#ff3399"></span><span style="color:#a71d5d">=</span>&nbsp;<span style="color:#0099cc">0</span>;</div><div style="padding:0 6px; white-space:pre; line-height:130%">&nbsp;</div><div style="background-color:#f0f0f0; padding:0 6px; white-space:pre; line-height:130%">&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#999999">//&nbsp;for&nbsp;문을&nbsp;돌면서&nbsp;값&nbsp;확인&nbsp;</span></div><div style="padding:0 6px; white-space:pre; line-height:130%">&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#a71d5d">for</span>&nbsp;(<span style="color:#066de2">int</span>&nbsp;i&nbsp;<span style="color:#ff3399"></span><span style="color:#a71d5d">=</span>&nbsp;<span style="color:#0099cc">0</span>;&nbsp;i&nbsp;<span style="color:#ff3399"></span><span style="color:#a71d5d">&lt;</span>&nbsp;<span style="color:#0099cc">9</span>&nbsp;<span style="color:#ff3399"></span><span style="color:#a71d5d">&amp;</span><span style="color:#ff3399"></span><span style="color:#a71d5d">&amp;</span>&nbsp;(isComplete&nbsp;<span style="color:#ff3399"></span><span style="color:#a71d5d">=</span><span style="color:#ff3399"></span><span style="color:#a71d5d">=</span>&nbsp;<span style="color:#0099cc">0</span>)&nbsp;;&nbsp;i<span style="color:#ff3399"></span><span style="color:#a71d5d">+</span><span style="color:#ff3399"></span><span style="color:#a71d5d">+</span>)&nbsp;{</div><div style="background-color:#f0f0f0; padding:0 6px; white-space:pre; line-height:130%">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#a71d5d">for</span>&nbsp;(<span style="color:#066de2">int</span>&nbsp;j&nbsp;<span style="color:#ff3399"></span><span style="color:#a71d5d">=</span>&nbsp;i<span style="color:#ff3399"></span><span style="color:#a71d5d">+</span><span style="color:#0099cc">1</span>;&nbsp;j&nbsp;<span style="color:#ff3399"></span><span style="color:#a71d5d">&lt;</span>&nbsp;<span style="color:#0099cc">9</span>&nbsp;<span style="color:#ff3399"></span><span style="color:#a71d5d">&amp;</span><span style="color:#ff3399"></span><span style="color:#a71d5d">&amp;</span>&nbsp;(isComplete&nbsp;<span style="color:#ff3399"></span><span style="color:#a71d5d">=</span><span style="color:#ff3399"></span><span style="color:#a71d5d">=</span>&nbsp;<span style="color:#0099cc">0</span>);&nbsp;j<span style="color:#ff3399"></span><span style="color:#a71d5d">+</span><span style="color:#ff3399"></span><span style="color:#a71d5d">+</span>)&nbsp;{</div><div style="padding:0 6px; white-space:pre; line-height:130%">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#999999">//&nbsp;i와&nbsp;j&nbsp;를&nbsp;제외하는&nbsp;넘버로&nbsp;지정&nbsp;</span></div><div style="background-color:#f0f0f0; padding:0 6px; white-space:pre; line-height:130%">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#066de2">int</span>&nbsp;sum&nbsp;<span style="color:#ff3399"></span><span style="color:#a71d5d">=</span>&nbsp;<span style="color:#0099cc">0</span>;</div><div style="padding:0 6px; white-space:pre; line-height:130%">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;answer_vec.clear();</div><div style="background-color:#f0f0f0; padding:0 6px; white-space:pre; line-height:130%">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#a71d5d">for</span>&nbsp;(<span style="color:#066de2">int</span>&nbsp;k&nbsp;<span style="color:#ff3399"></span><span style="color:#a71d5d">=</span>&nbsp;<span style="color:#0099cc">0</span>;&nbsp;k&nbsp;<span style="color:#ff3399"></span><span style="color:#a71d5d">&lt;</span>&nbsp;<span style="color:#0099cc">9</span>;&nbsp;k<span style="color:#ff3399"></span><span style="color:#a71d5d">+</span><span style="color:#ff3399"></span><span style="color:#a71d5d">+</span>)&nbsp;{</div><div style="padding:0 6px; white-space:pre; line-height:130%">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#a71d5d">if</span>&nbsp;((k&nbsp;<span style="color:#ff3399"></span><span style="color:#a71d5d">!</span><span style="color:#ff3399"></span><span style="color:#a71d5d">=</span>&nbsp;i)&nbsp;<span style="color:#ff3399"></span><span style="color:#a71d5d">&amp;</span><span style="color:#ff3399"></span><span style="color:#a71d5d">&amp;</span>&nbsp;(k&nbsp;<span style="color:#ff3399"></span><span style="color:#a71d5d">!</span><span style="color:#ff3399"></span><span style="color:#a71d5d">=</span>&nbsp;j))&nbsp;{</div><div style="background-color:#f0f0f0; padding:0 6px; white-space:pre; line-height:130%">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;answer_vec.<span style="color:#066de2">push_back</span>(small_people[k]);</div><div style="padding:0 6px; white-space:pre; line-height:130%">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sum&nbsp;<span style="color:#ff3399"></span><span style="color:#a71d5d">+</span><span style="color:#ff3399"></span><span style="color:#a71d5d">=</span>&nbsp;small_people[k];&nbsp;</div><div style="background-color:#f0f0f0; padding:0 6px; white-space:pre; line-height:130%">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</div><div style="padding:0 6px; white-space:pre; line-height:130%">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</div><div style="background-color:#f0f0f0; padding:0 6px; white-space:pre; line-height:130%">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#a71d5d">if</span>&nbsp;(sum&nbsp;<span style="color:#ff3399"></span><span style="color:#a71d5d">=</span><span style="color:#ff3399"></span><span style="color:#a71d5d">=</span>&nbsp;<span style="color:#0099cc">100</span>)&nbsp;isComplete&nbsp;<span style="color:#ff3399"></span><span style="color:#a71d5d">=</span>&nbsp;<span style="color:#0099cc">1</span>;</div><div style="padding:0 6px; white-space:pre; line-height:130%">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</div><div style="background-color:#f0f0f0; padding:0 6px; white-space:pre; line-height:130%">&nbsp;&nbsp;&nbsp;&nbsp;}</div><div style="padding:0 6px; white-space:pre; line-height:130%">&nbsp;</div><div style="background-color:#f0f0f0; padding:0 6px; white-space:pre; line-height:130%">&nbsp;&nbsp;&nbsp;&nbsp;sort(answer_vec.<span style="color:#066de2">begin</span>(),&nbsp;answer_vec.<span style="color:#066de2">end</span>());</div><div style="padding:0 6px; white-space:pre; line-height:130%">&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#a71d5d">for</span>&nbsp;(<span style="color:#066de2">int</span>&nbsp;i&nbsp;<span style="color:#ff3399"></span><span style="color:#a71d5d">=</span>&nbsp;<span style="color:#0099cc">0</span>;&nbsp;i&nbsp;<span style="color:#ff3399"></span><span style="color:#a71d5d">&lt;</span>&nbsp;<span style="color:#0099cc">7</span>;&nbsp;i<span style="color:#ff3399"></span><span style="color:#a71d5d">+</span><span style="color:#ff3399"></span><span style="color:#a71d5d">+</span>)</div><div style="background-color:#f0f0f0; padding:0 6px; white-space:pre; line-height:130%">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#066de2">cout</span>&nbsp;<span style="color:#ff3399"></span><span style="color:#a71d5d">&lt;</span><span style="color:#ff3399"></span><span style="color:#a71d5d">&lt;</span>&nbsp;answer_vec[i]&nbsp;<span style="color:#ff3399"></span><span style="color:#a71d5d">&lt;</span><span style="color:#ff3399"></span><span style="color:#a71d5d">&lt;</span>&nbsp;<span style="color:#63a35c">"\n"</span>;</div><div style="padding:0 6px; white-space:pre; line-height:130%">&nbsp;</div><div style="background-color:#f0f0f0; padding:0 6px; white-space:pre; line-height:130%">&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:#a71d5d">return</span>&nbsp;<span style="color:#0099cc">0</span>;&nbsp;</div><div style="padding:0 6px; white-space:pre; line-height:130%">}</div></div><div style="text-align:right; margin-top:-13px; margin-right:5px; font-size:9px; font-style:italic"><a href="http://colorscripter.com/info#e" target="_blank" style="color: rgb(229, 229, 229);">Colored by Color Scripter</a></div></td><td style="vertical-align: bottom; padding-right: 2px; padding-bottom: 4px;"><a href="http://colorscripter.com/info#e" target="_blank" style="color: white;"><span style="font-size: 9px; word-break: normal; background-color: rgb(229, 229, 229); border-radius: 10px; padding: 1px;">cs</span></a></td></tr></tbody></table></div>
You can’t perform that action at this time.