Cod sursă (job #361484)

Utilizator avatar eduardandrei20 Nechifor Eduard Andrei eduardandrei20 IP ascuns
Problemă SCV (clasele 9-10) Compilator cpp | 0,67 kb
Rundă Arhiva de probleme Status evaluat
Dată 7 mar. 2018 13:58:59 Scor 100
#include <bits/stdc++.h>


using namespace std;


int main ()
{
   freopen("scv.in" , "r" ,stdin);
   freopen("scv.out" , "w" , stdout);
  long long cost, timp, cant, x, t, masini, kg;

  scanf ("%lld%lld%lld%lld",&cost,&timp,&cant,&x);

  t = 0LL;
  masini = 1;
  kg = 0LL;
  while (kg < x)
  {
        while (kg < x && kg < cost)
        {
      kg += cant*masini;
      t ++;
      }
    if (kg + masini*cant*timp + cant*masini * (cost/cant)< x)
    {
      t += timp;
      kg += masini*cant*timp - cost;
      masini ++;
    }else
    while (kg < x){
        t ++;
        kg += cant*masini;
      }
  }

  printf("%lld",t);
  return 0;
}