QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#796384 | #9408. Hero of the Kingdom | 2317663977 | WA | 1ms | 3696kb | C++23 | 1.2kb | 2024-12-01 17:56:10 | 2024-12-01 17:56:10 |
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 = 1e18;
while (l < r)
{
ll mid = l + r + 1 >> 1;
if ((__int128)(a * x + b + c + x + d) * mid + 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: 100
Accepted
time: 0ms
memory: 3672kb
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 20 99
result:
ok 3 lines
Test #2:
score: -100
Wrong Answer
time: 1ms
memory: 3696kb
input:
500 252 34074578 3386884 628907 1207868 18 279 125908043 17268783 50414369 277106 17532337 45 0 17268784 4606 5506 3465964 19 5543 4786900 7 8109756 50825 23718927 66546966 0 23718931 96 0 117090491 99433206 537909 33389755 4 537910 1362118 0 538731 3 47 117 17333 1724743 7699 402536 79710763 684241...
output:
1886244 17268784 8109756 117090495 538731 136625731 586 25929035 17864 7905961573 38782804 732671853 16635 93206034 4502 3995 6379706119 1070452 134333292 495166 1476765863 156 598405696216 53895 3503164 4727693 124349483 3764139838369 2553388228543572 85930602 4319452 996195 54156125533 32693 49185...
result:
wrong answer 12th lines differ - expected: '670869825', found: '732671853'