QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#796385 | #9408. Hero of the Kingdom | 2317663977 | WA | 1ms | 3736kb | C++23 | 1.2kb | 2024-12-01 17:57:45 | 2024-12-01 17:57:45 |
Judging History
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;
}
详细
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'