페이지

12791번: Starman

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


$O(q)$


#include<cstdio>
int y[25] = { 1967,1969,1970,1971,1972,1973,1973,1974,1975,1976,1977,1977,1979,1980,1983,1984,1987,1993,1995,1997,1999,2002,2003,2013,2016 };
char s[25][51] = { "DavidBowie","SpaceOddity","TheManWhoSoldTheWorld","HunkyDory","TheRiseAndFallOfZiggyStardustAndTheSpidersFromMars","AladdinSane","PinUps","DiamondDogs","YoungAmericans","StationToStation","Low","Heroes","Lodger","ScaryMonstersAndSuperCreeps","LetsDance","Tonight","NeverLetMeDown","BlackTieWhiteNoise","1.Outside","Earthling","Hours","Heathen","Reality","TheNextDay","BlackStar" };
int q, a, b, r[25];
int main() {
    scanf("%d", &q);
    while (q--) {
        scanf("%d %d", &a, &b);
        int c = 0;
        for (int i = 0; i < 25; i++) if (y[i] >= a && y[i] <= b) r[c++] = i;
        printf("%d\n", c);
        for (int i = 0; i < c; i++) printf("%d %s\n", y[r[i]], s[r[i]]);
    }
    return 0;
}

댓글 없음 :

댓글 쓰기