Pagini recente »
Clasament concurs_simplu2
|
Borderou de evaluare (job #520019)
|
Monitorul de evaluare
|
Rating Corman Denis (deniscorman)
|
Cod sursă (job #465526)
Cod sursă (job
#465526)
#include <bits/stdc++.h>
using namespace std;
int c,t,m,x,nr,tot,ans;
int main()
{
ifstream cin("scv.in");
ofstream cout("scv.out");
cin>>c>>t>>m>>x;
nr = 1;
tot = 0;
while(tot < x)
{
while(tot<x && tot<c)
{
ans++;
tot+=m*nr;
}
if(tot>=x) break;
if(tot + nr*m*t < x - m*nr*(c/m))
{
ans+=t;
tot-=c;
tot+=nr*m*t;
nr++;
}
else
{
while(tot<x)
{
ans++;
tot+=m*nr;
}
}
}
cout<<ans;
return 0;
}