QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#796385#9408. Hero of the Kingdom2317663977WA 1ms3736kbC++231.2kb2024-12-01 17:57:452024-12-01 17:57:45

Judging History

你现在查看的是最新测评结果

  • [2024-12-01 17:57:45]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3736kb
  • [2024-12-01 17:57:45]
  • 提交

answer

#include <iostream>
using namespace std;
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <cstring>

using ll = long long;

ll p, a, b;
ll q, c, d;
ll m, t;


void solve()
{
	cin >> p >> a >> b;
	cin >> q >> c >> d;
	cin >> m >> t;
	
	if (m / p == 0)
	{
		cout << m << '\n';
		return;
	}

	ll now = 0;
	while (now < t)
	{
		ll x = m / p;
		//cout << x << ' ' << m  << '\n';
		if (x == 0) break;

		ll zen = (q - p) * x;
		ll zenm = p - m % p;
		ll xx = zenm / zen;
		if (zenm % zen != 0) xx++;

		if ((a * x + b + c * x + d) * xx + now <= t)
		{
			m += (q - p) * x * xx;
			now += (a * x + b + c * x + d) * xx;
		}
		else
			break;
	}

	ll x = m / p;
	
	ll zen = (q - p) * x;
	ll l = 0, r = 1e9;
	while (l < r)
	{
		ll mid = l + r + 1 >> 1;
		if (a * mid + b + c * mid + d + now <= t) l = mid;
		else r = mid - 1;
	}
	//cout << l << '\n';
	m += zen * l;
	now += (a * x + b + c * x + d) * l;

	x = (t - now - d - b) / (a + c);
	if (x > 0) m += (q - p) * x;

	cout << m << '\n';
}

int main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int T = 1;
	cin >> T;
	while (T--)
	{
		solve();
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3736kb

input:

3
5 2 3
8 1 5
14 36
5 2 0
8 1 3
17 6
100 1 0
10000 1 0
99 100000

output:

32
26
99

result:

wrong answer 2nd lines differ - expected: '20', found: '26'