Pagini recente »
Istoria paginii utilizator/vladaturcan
|
Rating Dragos (Arsene_Dragos)
|
Istoria paginii utilizator/theodorapanainte
|
Istoria paginii runda/2016-10-05-test-7-8/clasament
|
Cod sursă (job #128410)
Cod sursă (job
#128410)
#include <cstdio>
#include <algorithm>
using namespace std;
long long c , t , m , x , tmp , zile_nou , ramas , copie , SCV , SOL;
long long timp(long long nr , long long m , long long cost)
{
if (cost <= 0) return 0;
long long cat = cost / (nr * m);
if (cost % (nr * m) == 0) return cat;
return cat + 1;
}
int main()
{
freopen("scv.in","r",stdin);
freopen("scv.out","w",stdout);
scanf("%lld %lld %lld %lld", &c , &t , &m , &x);
/// c - costul unui nou SCV
/// t - timpul unui nou SCV
/// m - cantitatea pe zi
/// x - target
SCV = 1LL; tmp = timp(SCV , m , x); SOL = zile_nou = tmp;
for ( ; SCV < x ; ++SCV)
{
zile_nou -= timp(SCV , m , x - ramas); copie += zile_nou;
zile_nou = timp(SCV , m , c - ramas); ramas += SCV * zile_nou * m - c;
zile_nou += t; ramas += SCV * t * m;
zile_nou += timp(SCV + 1 , m , x - ramas);
SOL = min(SOL , zile_nou + copie);
//if (SOL != zile_nou + copie) break;
}
printf("%lld\n", SOL);
return 0;
}