본문 바로가기

카테고리 없음

(C++) - 백준(BOJ) 12791번 : Starman

반응형

https://www.acmicpc.net/problem/12791

 

12791번: Starman

첫 번째 줄에 질의의 수 정수 Q(Q ≤ 100)가 주어진다. 이후 Q개의 줄에 질의 S, E(1 ≤ S ≤ E ≤ 2016)가 정수로 주어진다.

www.acmicpc.net

단순 출력 문제였습니다.

 

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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
//1972년 부터 2016년 까지 25개의 앨범을 냈다.
string a[25][2= {
    "1967""DavidBowie",
    "1969""SpaceOddity",
    "1970""TheManWhoSoldTheWorld",
    "1971""HunkyDory",
    "1972""TheRiseAndFallOfZiggyStardustAndTheSpidersFromMars",
    "1973""AladdinSane",
    "1973""PinUps",
    "1974""DiamondDogs",
    "1975""YoungAmericans",
    "1976""StationToStation",
    "1977""Low",
    "1977""Heroes",
    "1979""Lodger",
    "1980""ScaryMonstersAndSuperCreeps",
    "1983""LetsDance",
    "1984""Tonight",
    "1987""NeverLetMeDown",
    "1993""BlackTieWhiteNoise",
    "1995""1.Outside",
    "1997""Earthling",
    "1999""Hours",
    "2002""Heathen",
    "2003""Reality",
    "2013""TheNextDay",
    "2016""BlackStar",
};
int q,s,e;
int main() {
    cin >> q;
    while (q--)
    {
        int ans = 0;
        cin >> s >> e;
        for (int i = 0; i < 25; i++)
            if (stoi(a[i][0]) >= s && stoi(a[i][0]) <= e)
                ans++;
        cout << ans << '\n';
        for (int i = 0; i < 25; i++)
            if (stoi(a[i][0]) >= s && stoi(a[i][0]) <= e)
                cout << a[i][0<< ' ' << a[i][1<< '\n';
 
    }
}
cs