알고리즘

C++ 알고리즘 - 1476 날짜 계산

마루설아 2025. 1. 19. 20:05

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

 

#include <bits/stdc++.h>
#define endl "\n"

using namespace std;

void CPP_INIT() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
}

int main(void) {
	CPP_INIT();

	int E, S, M;
	int ans = -1;
	cin >> E >> S >> M;

	while (E != 1 || S != 1 || M != 1) {
		E--;
		S--;
		M--;

		if (E < 1) E = 15;
		if (S < 1) S = 28;
		if (M < 1) M = 19;

		ans--;
	}

	cout << abs(ans);
}