Pentru această operație este nevoie să te autentifici.
Pentru această operație este nevoie să te autentifici.
Cod sursă (job #470675)
Utilizator |
|
IP | ascuns |
---|---|---|---|
Problemă | SCV (clasele 9-10) | Compilator | cpp | 1,26 kb |
Rundă | Arhiva de probleme | Status | evaluat |
Dată | 14 apr. 2019 20:53:51 | Scor | 0 |
#include<bits/stdc++.h>
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 ) ;
cin>>cost>>tcost>>kg>>norma;
if( cost % kg == 0 )
{
ratie = cost ;
ziua = cost / kg ;
}
else
{
ratie = ( cost / kg + 1 ) * kg ;
ziua = cost / kg + 1 ;
}
while( ( norma - ratie ) / ( SCV * kg ) >= ( norma - ratie + cost - SCV * kg * tcost ) / ( ( SCV + 1 ) * kg ) + tcost && ratie < norma )
{
++ SCV ;
ratie = ratie - cost ;
ziua = ziua + tcost ;
ratie = ratie + ( SCV - 1 ) * kg * tcost ;
if( ratie < cost )
{
if( ( cost - ratie ) % ( SCV * kg ) == 0 )
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)==0)
d=(norma-ratie)/(SCV*kg);
else
d=(norma-ratie)/(SCV*kg)+1;
ziua=ziua+d;
}
cout<<d;
return 0 ;
}