57092023-09-09 18:21:09TomaSajtVilágnaptár (45 pont)cpp17Accepted 45/453ms4204 KiB
#include <bits/stdc++.h>
using namespace std;

vector<int> month_lengths = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
vector<int> w_month_lengths = {31, 30, 30, 31, 30, 30, 31, 30, 30, 31, 30, 31};

int main() {
  int year, month_ind, month_day_ind;
  cin >> year >> month_ind >> month_day_ind;
  month_day_ind--;
  month_ind--;

  if (year % 4 == 0) {
    month_lengths[1]++;
    w_month_lengths[5]++;
  }

  int day_index = month_day_ind;
  for (int i = 0; i < month_ind; i++) {
    day_index += month_lengths[i];
  }

  int w_month_ind = 0;
  int w_month_day_index = day_index;
  while (w_month_day_index >= w_month_lengths[w_month_ind]) {
    w_month_day_index -= w_month_lengths[w_month_ind];
    w_month_ind++;
  }

  cout << year << ' ' << w_month_ind + 1 << ' ';
  if (w_month_ind == 5 && w_month_day_index == 30) {
    cout << "SZN";
  }
  else if (w_month_ind == 11 && w_month_day_index == 30) {
    cout << "VN";
  }
  else {
    cout << w_month_day_index + 1;
  }
}
SubtaskSumTestVerdictTimeMemory
base45/45
1Accepted0/03ms1812 KiB
2Accepted0/03ms2012 KiB
3Accepted0/03ms2252 KiB
4Accepted2/23ms2464 KiB
5Accepted2/23ms2684 KiB
6Accepted3/33ms2900 KiB
7Accepted3/33ms3112 KiB
8Accepted3/33ms3232 KiB
9Accepted3/33ms3436 KiB
10Accepted3/33ms3624 KiB
11Accepted3/33ms3840 KiB
12Accepted3/32ms3924 KiB
13Accepted3/33ms3932 KiB
14Accepted3/32ms3936 KiB
15Accepted3/33ms4056 KiB
16Accepted3/33ms4180 KiB
17Accepted3/33ms4192 KiB
18Accepted2/22ms4200 KiB
19Accepted3/32ms4204 KiB