백준 1476번 : 날짜계산

Se0ng_1l·2022년 6월 22일
0

백준

목록 보기
5/40

무한반복을 통해 3입력값과 같아지는 시점에 결과물을 출력한다.

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

#include <iostream>
using namespace std;

int main()
{
    int e, s, m;
    cin >> e >> s >> m;
    int i = 0;
    int a = 0, b = 0, c = 0;
    while(true)
    {
        if(a == 16)
            a = 1;
        if(b == 29)
            b = 1;
        if(c == 20)
            c = 1;
        if(e == a && s == b && m == c)
        {
            break;
        }
        a++; b++; c++;
        i++;
    }
    cout << i << endl;
}
profile
치타가 되고 싶은 취준생

0개의 댓글