Source Code
#include <iostream>
#include <cmath> 
using namespace std;
int main()
{
	long double l, r, count, sum = 0,cyc;
	int x, y, k;
	cin >> l >> r >> x >> y >> k;
	
	for (long long i = l; i <= r; i++)
	{
		count = i;
		cyc = ceil(count / k);
		for (long long j = 0; j < cyc; j++)
		{
			if (count > k)
			{
				sum += x * k;
				sum += y;
			}
			else if (count <= k)
			{
				sum += count * x;
			}
			count -= k;
		}

	}
	cout << sum;
}
Copy
Practice Practice master2000
GNU G++17
1099 ms
392 KB
Time Limit Exceeded