QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#421300 | #6823. Coffee Overdose | kjhhjki | WA | 0ms | 3664kb | C++20 | 1.1kb | 2024-05-25 16:15:12 | 2024-05-25 16:15:13 |
Judging History
answer
#include <bits/stdc++.h>
#define For(i, a, b) for(i32 i = (a), endi = (b); i <= endi; ++i)
#define foR(i, a, b) for(i32 i = (a), endi = (b); i >= endi; --i)
using namespace std;
template<typename T, typename U>
void chkmin(T &a, U b) { if(a > b) a = b; }
template<typename T, typename U>
void chkmax(T &a, U b) { if(a < b) a = b; }
using i32 = int;
using i64 = long long;
using f64 = long double;
int mp[128];
void init()
{
For(i, '0', '9') mp[i] = i - '0';
For(i, 'a', 'z') mp[i] = i - 'a' + 10;
}
void solve()
{
i32 c, s;
cin >> s >> c;
auto get = [s, c](i32 t)
{
i64 res = (s + s - t + 2ll) * (t-1) / 2;
i64 tmp = 0;
i32 a = s - t + 1, d = c + 1, k = a / d + 1;
// cout << a << ' ' << d << ' ' << k << '\n';
tmp = 1ll * (a + (a % d)) * (k) / 2;
return res + tmp * c;
};
i64 ans = get(1);
for(i32 i = c; i <= min(c * (c+1ll) / 2, 1ll*s); i += c) chkmax(ans, get(i));
cout << ans << '\n';
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
init();
i32 T = 1;
cin >> T;
while(T--) solve();
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3664kb
input:
4 1 2 2 1 10 4 172800 172800
output:
2 2 63 29859840000
result:
wrong answer 2nd words differ - expected: '3', found: '2'