Cod sursă (job #371975)

Utilizator avatar Danut200333 Dumitru Alexandru Daniel Danut200333 IP ascuns
Problemă SCV (clasele 9-10) Compilator cpp | 0.59 kb
Rundă Arhiva de probleme Status evaluat
Dată 27 mar. 2018 21:20:55 Scor 100
#include <fstream>

using namespace std;
ifstream fin("scv.in");
ofstream fout("scv.out");
int c,t,m,x,nr,sm,nr1;
int main()
{

    fin>>c>>t>>m>>x;
    sm=0;
    nr=1;
    nr1=0;
    while(sm<x)
    {
        while(sm<x&&sm<c)
        {
            sm+=m*nr;
            nr1++;
        }
        if (sm+nr*m*t+m*nr*(c/m)< x)
        {
            nr1+=t;
            sm+=t*nr*m-c;
            nr++;
        }
        else
            while(sm<x)
            {
                sm+=nr*m;
                nr1++;

            }
    }

    fout<<nr1;
    return 0;
}