Cod sursă (job #107956)

Utilizator avatar dummy contdezactivat dummy IP ascuns
Problemă SCV (clasele 9-10) Compilator cpp | 1,21 kb
Rundă Tema 12 clasele 9-10 2014/15 Status evaluat
Dată 19 ian. 2015 22:23:34 Scor 32
#include<cstdio>

using namespace std;

int  norma , ratie , ziua , d , cost , tcost , kg ;

int main()
{
    int SCV = 1 ;

    freopen( "scv.in" , "r" , stdin ) ;
    freopen( "scv.out" , "w" , stdout ) ;

    scanf( "%d%d%d%d" , &cost , &tcost , &kg , &norma  ) ;

    if( !cost % kg )
      {
       ratie = cost ;
       ziua = cost / kg ;
      }
    else
       {
        ratie = ( cost / kg  + 1 ) * kg ;
        ziua = cost / kg + 1 ;
       }
    while( ( norma - ratie ) / SCV >= ( norma - ratie + cost - SCV * kg * tcost ) / ( SCV + 1 ) + tcost && ratie < norma )
         {
          ++ SCV ;
          ratie = ratie - cost ;

          d = tcost ;
          while( d && ratie < norma )
               {
                ++ ziua ;
                ratie = ratie + ( SCV - 1 ) * kg ;
                d -- ;
               }
          while( ratie < cost )
               {
                ++ ziua ;
                ratie = ratie + SCV * kg ;
               }
         }
    while( ratie < norma )
         {
          ++ ziua  ;
          ratie = ratie  +  kg * SCV ;
         }
    printf( "%d " , ziua - 1  ) ;
    ///printf( "\nIisuse miluieste - ma ") ;
    return 0 ;
}