Cod sursă (job #299906)

Utilizator avatar adriananicolae Adriana Nicolae adriananicolae IP ascuns
Problemă SCV (clasele 9-10) Compilator cpp | 0,58 kb
Rundă Arhiva de probleme Status evaluat
Dată 10 apr. 2017 21:14:12 Scor 100
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int i,j,c,m,x,t,mi;
int tt,tm;
int main()
{
    freopen("scv.in","r",stdin);
    freopen("scv.out","w",stdout);
    scanf("%d %d %d %d",&c,&t,&m,&x);
    mi=m;
    while (tm<x)
    {
        while (tm<min(x,c))
        ++tt,tm=tm+m;
        if (tm+m*t+m*(c/mi)<x)
        {
            tm=tm+(m*t-c);
            tt=t+tt;
            m=m+mi;
        }else
        {
            if ((x-tm)%m!=0) tt++;
            tt=tt+(x-tm)/m; tm=x;
        }
    }
    printf("%d",tt);
    return 0;
}