Cod sursă (job #465381)

Utilizator avatar IonBordea1408 Ion Bordea IonBordea1408 IP ascuns
Problemă SCV (clasele 9-10) Compilator cpp | 0,54 kb
Rundă Arhiva de probleme Status evaluat
Dată 2 apr. 2019 18:47:38 Scor 0
#include<bits/stdc++.h>
using namespace std;

/*ifstream fin("input.in");
ofstream fout("output.out");*/

ifstream fin("scv.in");
ofstream fout("scv.out");

int x,c,t,m,m1,rs;
int kg;
int xc1,xc,xb;
int q;

int main(){
	fin >> c >> t >> m >> x;
	m1=m;
	
	xb=xc=(x/m)+((x%m)>0);
	while(xc==xb){
		if(kg>=c){
			kg-=50;
		}else{
			xc=xc1+(c-kg)/m+(((c-kg)%m)>0);
			kg=m*(xc-xc1)-50+kg;
		}
		xc+=t;
		kg+=m*t;
		m+=m1;
		xc1=xc;
		xc+=(x-kg)/m+(((x-kg)%m)>0);
		xb=(xb>xc)?(xc):(xb);
	}
	
	fout << xb;
	
	return 0;
}