Pagini recente »
Istoria paginii runda/recapitulare10
|
Istoria paginii runda/lasm_20_01_2021_cl11
|
Istoria paginii runda/2016-04-20-test-6/clasament
|
Istoria paginii utilizator/dogslover
|
Cod sursă (job #107348)
Cod sursă (job
#107348)
#include <cstdio>
using namespace std;
int c,t,m,x;
void citire()
{
freopen("scv.in","r",stdin);
freopen("scv.out","w",stdout);
scanf("%d%d%d%d",&c,&t,&m,&x);
}
int z;
int nrscv;
int t_constructie;
int minerale;
int nrzile(int min, int scv)
//numarul de zile ca cantitatea min sa fie adunate de scv scv-uri
{
int raspuns = min / (scv * m);
if (raspuns % (scv * m) > 0)
++raspuns;
return raspuns;
}
void simulare()
{
nrscv = 1;
minerale = 0;
for (z = 0;minerale < x;minerale += nrscv * m,++z)
{
if (t_constructie > 0)
{
--t_constructie;
if (t_constructie == 0)
++nrscv;
}
if (minerale >= c && t_constructie == 0 && nrzile(x - minerale, nrscv) > t + nrzile(c, 1))
{//comanda de constructie a unui scv
t_constructie = t;
minerale -= c;
}
}
}
int main()
{
citire();
simulare();
printf("%d\n",z);
return 0;
}