Algorithm/📖Baekjoon
#1476 날짜 계산
yewoneeee
2022. 8. 3. 16:23
# 문제
# 입력 및 출력
# 풀이
처음엔 최소공배수로 찾아야하나 싶었는데
그냥 하나하나 비교해가면서 찾는게 맞는 것 같아서
무한 반복문으로 해결했음
#include <iostream>
using namespace std;
int main() {
int e, s, m, te = 1, ts = 1, tm = 1;
int year = 1;
cin >> e >> s >> m;
while (1) {
if (te == e && ts == s && tm == m) break;
year++;
te = ++te > 15 ? te - 15 : te;
ts = ++ts > 28 ? ts - 28 : ts;
tm = ++tm > 19 ? tm - 19 : tm;
}
cout << year << "\n";
}