Cod sursă (job #560707)

Utilizator avatar andrei_marciuc Marciuc Andrei andrei_marciuc IP ascuns
Problemă SCV (clasele 9-10) Compilator cpp | 0,75 kb
Rundă Arhiva de probleme Status evaluat
Dată 16 iul. 2020 15:13:30 Scor 100
#include <fstream>
using namespace std;
ifstream cin( "scv.in" );
ofstream cout( "scv.out" );
int scv, mineral, zile;

int main()
{
    int pp,c, t, m, x;
    cin >> c >> t >> m >> x;
    scv = m;
    while( mineral < x ){
        pp = x;
        if( pp > c )
            pp = c;
        while( mineral < pp ){
            zile++;
            mineral += m;
        }
        if( mineral + m * t + m * ( c / scv ) >= x ){
            if( ( x - mineral ) % m != 0 )
                zile++;
            zile = zile + ( x - mineral ) / m;
            mineral = x;
        } else {
            mineral = mineral + ( m * t - c );
            zile = t + zile;
            m = m + scv;

        }
    }
    cout << zile << '\n';
    return 0;
}