Cod sursă (job #561676)

Utilizator avatar pofian abc abc pofian IP ascuns
Problemă SCV (clasele 9-10) Compilator cpp | 0,64 kb
Rundă Arhiva de probleme Status evaluat
Dată 30 iul. 2020 11:50:34 Scor 100
#include <fstream>
using namespace std;
ifstream fin ("scv.in");
ofstream fout("scv.out");
int c,t,m,x,productie,mats,zile,f,g,h;

int ceiling(int p,int q)
{
    return (p>0)*(p/q+bool(p%q));
}

int main()
{
    fin>>c>>t>>m>>x;
    f=min(c,x);
    productie=m;
    h=c/m+t;
    while(1)
    {
        g=ceiling(f-mats,productie);
        zile+=g;
        mats+=productie*g;
        if(productie*h<x-mats)
        {
            zile+=t;
            mats+=(productie*t-c);
            productie+=m;
        }
        else
        {
            fout<<zile+ceiling(x-mats,productie);
            return 0;
        }
    }
}