본문 바로가기
Algorithm/📖Baekjoon

#1476 날짜 계산

by yewoneeee 2022. 8. 3.

# 문제

# 입력 및 출력

# 풀이

처음엔 최소공배수로 찾아야하나 싶었는데

그냥 하나하나 비교해가면서 찾는게 맞는 것 같아서

무한 반복문으로 해결했음

#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";
}

 

'Algorithm > 📖Baekjoon' 카테고리의 다른 글

#18352 특정 거리의 도시 찾기  (0) 2022.08.05
#1449 수리공 항승  (0) 2022.08.04
#6603 로또  (0) 2022.08.02
#4796 캠핑  (0) 2022.07.25
#1302 베스트셀러  (0) 2022.07.24

댓글