57192023-09-09 19:54:10kukkermanVilágnaptár (45 pont)cpp14Accepted 45/453ms3576 KiB
#include <iostream>
#include <array>

void beolvas(std::istream &in, int &ev, int &ho, int &nap) {
    in >> ev >> ho >> nap;
}

void feldolgoz(int ev, int ho, int nap) {
    static constexpr std::array<int, 12> gergely{
        31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
    };

    static constexpr std::array<int, 12> vilag{
        31, 30, 30, 31, 30, 30, 31, 30, 30, 31, 30, 30
    };

    const bool szokoev = ev % 4 == 0;

    int n = nap;
    for (auto i = 1; i < ho; i++) {
        n += gergely[i - 1];
    }
    if (szokoev && ho >= 3) {
        n++;
    }

    int vh = 1;
    if (szokoev) {
        while (vh <= 6 && n > vilag[vh - 1]) {
            n -= vilag[vh - 1];
            vh++;
        }

        if (vh > 6) {
            n--;
        }
    }
    while (vh <= 12 && n > vilag[vh - 1]) {
        n -= vilag[vh - 1];
        vh++;
    }

    std::cout << ev << ' ';
    if (vh == 13) {
        std::cout << " 12 VN";

    } else if (n == 0) {
        std::cout << " 6 SZN";

    } else {
        std::cout << vh << ' ' << n;
    }
    std::cout << std::endl;
}

int main() {
    int ev, ho, nap;

    beolvas(std::cin, ev, ho, nap);
    feldolgoz(ev, ho, nap);

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base45/45
1Accepted0/03ms1748 KiB
2Accepted0/02ms1912 KiB
3Accepted0/02ms2160 KiB
4Accepted2/22ms2332 KiB
5Accepted2/22ms2420 KiB
6Accepted3/32ms2416 KiB
7Accepted3/32ms2420 KiB
8Accepted3/32ms2548 KiB
9Accepted3/32ms2788 KiB
10Accepted3/32ms2840 KiB
11Accepted3/32ms2844 KiB
12Accepted3/32ms2872 KiB
13Accepted3/32ms2984 KiB
14Accepted3/32ms3056 KiB
15Accepted3/32ms3172 KiB
16Accepted3/32ms3184 KiB
17Accepted3/33ms3376 KiB
18Accepted2/22ms3500 KiB
19Accepted3/32ms3576 KiB