Classrooms and Calculators
시간 제한1초메모리 제한2048 MB
세 친구가 각각 0일과 d_i일 간격의 배수일마다 못 노는 상황에서, n일을 채우고 캠페인을 끝내는 날짜를 구한다.
문제
You're trying to organize a group of yourself and friends to play a campaign of your favorite tabletop game, Classrooms & Calculators. Your schedule is free every day, but your friends all have some scheduling conflicts. Let today be day , tomorrow be day , etc. Your first friend can't play today or every days after today, your second friend can't play today or every days after today, and your third friend can't play today or every days after today. You can only play on a day if nobody has a conflict, and you always play on days with no conflicts. For example, if , , and , in the first days you would play on days , , and , but not on days , , , , , , , and .
Your campaign's Classroom Teacher has told you that it will take days of playing to complete the campaign; can you determine the number of the day you finish the campaign?
입력
The first line of the input contains the values of , and (each between and , inclusive), each separated by a single space, describing your friends' schedule conflicts. The second line contains , the number of days you will need to play on to complete the campaign .
You are guaranteed that the values of , , and are such that you can complete the campaign in finite time.
출력
You should output a single number, the number of the day on which you finish the campaign.