Cod sursă (job #543353)

Utilizator avatar bitldreea andreea bitlan bitldreea IP ascuns
Problemă SCV (clasele 9-10) Compilator cpp | 0.47 kb
Rundă Arhiva de probleme Status evaluat
Dată 14 mar. 2020 10:08:32 Scor 100
#include <bits/stdc++.h>
using namespace std;

int main()
{
	ifstream cin("scv.in");
	ofstream cout("scv.out");
	int n, m, k, l, cs = 1, time = 0, current = 0;
	cin >> n >> m >> k >> l;
	while (current < l)
	{
		while (current < l && current < n)
			time ++, current += cs * k;
		if (current + m * cs * k + cs * k * (n / k) < l)
			current += cs * k * m - n, time += m, cs++;
		else while (current < l)
			time ++, current += cs * k;
	}
	cout << time;
	return 0;
}