Pagini recente »
Cod sursă (job #321824)
|
Istoria paginii runda/s20_lab1_10/clasament
|
Profil Horia_haivas
|
Diferențe pentru runda/tema11-juniori-2014-2015 între reviziile 1 și 3
|
Cod sursă (job #107977)
Cod sursă (job
#107977)
#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 ;
ziua = ziua + tcost ;
ratie = ratie + ( SCV - 1 ) * kg * tcost ;
if( ratie < cost )
{
if( !( ( cost - ratie ) % ( SCV * kg ) ) )
d = ( cost - ratie ) / ( SCV * kg ) ;
else
d = ( cost - ratie ) / ( SCV * kg ) + 1 ;
ratie = ratie + kg * SCV * d ;
ziua = ziua + d ;
}
}
if( norma > ratie )
{
if( !( ( norma - ratie ) % ( SCV * kg ) ) )
d = ( norma - ratie ) / ( SCV * kg ) ;
else
d = ( norma - ratie ) / ( SCV * kg ) ;
ziua = ziua + d ;
}
printf( "%d" , ziua ) ;
//printf( "\nIisuse miluieste - ma ") ;
return 0 ;
}