https://www.acmicpc.net/problem/1333
#include <iostream>
using namespace std;
int main() {
int n,l,d;
cin>>n>>l>>d;
l+=5;
int num=0;
int time=d;
for(int i=0;i<n;i++){
num+=l;
for(;;){
if(time<num-5) time+=d;
else break;
}
if(num-5<=time&&time<num) break;
}
cout<<time;
}