Cod sursă (job #416201)

Utilizator avatar AndreiSofei Sofei Andrei-Adrian AndreiSofei IP ascuns
Problemă SCV (clasele 9-10) Compilator cpp | 0,72 kb
Rundă concurs__6_11 Status evaluat
Dată 6 ian. 2019 11:46:05 Scor 100
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("scv.in");
ofstream g("scv.out");
int cost,timp,cantit,S,s,K,T;
int main ()
{
    f>>cost>>timp>>cantit>>S;
    s=0;
    K=1;
    while(s<S){
            while(s<S && s<cost){
                    s=s+K*cantit;
                    T++;
            }
            if(s+K*cantit*timp+cantit*K*(cost/cantit)<S){
                    T=T+timp;
                    s=s-cost;
                    s=s+timp*K*cantit;
                    K++;
            }
            else{
                    while(s<S){
                            s=s+K*cantit;
                            T++;
                    }
            }
    }
    g<<T;
    return 0;
}