https://www.acmicpc.net/problem/1333
using System;
class Program
{
static void Main() {
string[] s=Console.ReadLine().Split(' ');
int n=int.Parse(s[0]);
int l=int.Parse(s[1])+5;
int d=int.Parse(s[2]);
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;
}
Console.Write(time);
}
}