File tree Expand file tree Collapse file tree 3 files changed +62
-0
lines changed Expand file tree Collapse file tree 3 files changed +62
-0
lines changed Original file line number Diff line number Diff line change 1+ #include < string>
2+ #include < vector>
3+ #include < iostream>
4+ using namespace std ;
5+
6+ vector<int > solution (int n, long long left, long long right) {
7+ vector<int > answer;
8+
9+ int ln = left / n;
10+ int lm = left % n;
11+ int rn = right / n;
12+ int rm = right % n;
13+
14+ // 왼쪽
15+ if (ln != rn) {
16+ for (int i = lm + 1 ; i <= n; ++i) {
17+ if (i < ln + 1 )
18+ answer.push_back (ln + 1 );
19+ else
20+ answer.push_back (i);
21+ }
22+
23+ // 중간
24+ for (int i = ln + 1 ; i < rn; ++i) {
25+ for (int k = 0 ; k < i + 1 ; ++k)
26+ answer.push_back (i + 1 );
27+ for (int j = i + 2 ; j <= n; ++j)
28+ answer.push_back (j);
29+ }
30+
31+ // 오른쪽
32+ for (int i = 0 ; i <= rm; ++i) {
33+ if (i < rn + 1 )
34+ answer.push_back (rn + 1 );
35+ else
36+ answer.push_back (i + 1 );
37+ }
38+ }
39+ else {
40+ for (int i = lm; i <= rm; ++i) {
41+ if (i < rn + 1 )
42+ answer.push_back (rn + 1 );
43+ else
44+ answer.push_back (i + 1 );
45+ }
46+ }
47+
48+ return answer;
49+ }
50+
51+ int main () {
52+ vector<int > ans = solution (4 ,4 ,7 );
53+ for (auto a : ans)
54+ cout << a << " " ;
55+ return 0 ;
56+ }
Original file line number Diff line number Diff line change 191191 <ClCompile Include =" Lv2\Lv2_JadenCase문자열만들기.cpp" >
192192 <ExcludedFromBuild Condition =" '$(Configuration)|$(Platform)'=='Debug|x64'" >true</ExcludedFromBuild >
193193 </ClCompile >
194+ <ClCompile Include =" Lv2\Lv2_n^2배열자르기.cpp" >
195+ <ExcludedFromBuild Condition =" '$(Configuration)|$(Platform)'=='Debug|x64'" >true</ExcludedFromBuild >
196+ </ClCompile >
194197 <ClCompile Include =" Lv2\Lv2_N개의최소공배수.cpp" >
195198 <ExcludedFromBuild Condition =" '$(Configuration)|$(Platform)'=='Debug|x64'" >true</ExcludedFromBuild >
196199 </ClCompile >
Original file line number Diff line number Diff line change 591591 <ClCompile Include =" Lv2\Lv2_이진변환반복하기.cpp" >
592592 <Filter >소스 파일\Lv2</Filter >
593593 </ClCompile >
594+ <ClCompile Include =" Lv2\Lv2_n^2배열자르기.cpp" >
595+ <Filter >소스 파일\Lv2</Filter >
596+ </ClCompile >
594597 </ItemGroup >
595598 <ItemGroup >
596599 <None Include =" packages.config" />
You can’t perform that action at this time.
0 commit comments