[백준 32154] SUAPC 2024 Winter (C#, C++) - soo:bak
작성일 :
문제 링크
설명
순위 N에 해당하는 정답 목록을 그대로 출력하는 문제입니다.
접근법
순위별 정답 목록이 고정되어 있으므로 배열에 미리 저장해 둡니다.
이후 입력받은 순위에 해당하는 문자열을 그대로 출력하면 됩니다.
Code
C#
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
using System;
class Program {
static void Main() {
var s = new[] {
"",
"11\nA B C D E F G H J L M",
"9\nA C E F G H I L M",
"9\nA C E F G H I L M",
"9\nA B C E F G H L M",
"8\nA C E F G H L M",
"8\nA C E F G H L M",
"8\nA C E F G H L M",
"8\nA C E F G H L M",
"8\nA C E F G H L M",
"8\nA B C F G H L M"
};
var n = int.Parse(Console.ReadLine()!);
Console.WriteLine(s[n]);
}
}
C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
string s[11] = {
"",
"11\nA B C D E F G H J L M",
"9\nA C E F G H I L M",
"9\nA C E F G H I L M",
"9\nA B C E F G H L M",
"8\nA C E F G H L M",
"8\nA C E F G H L M",
"8\nA C E F G H L M",
"8\nA C E F G H L M",
"8\nA C E F G H L M",
"8\nA B C F G H L M"
};
int n; cin >> n;
cout << s[n] << "\n";
return 0;
}