QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#421300#6823. Coffee OverdosekjhhjkiWA 0ms3664kbC++201.1kb2024-05-25 16:15:122024-05-25 16:15:13

Judging History

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

  • [2024-05-25 16:15:13]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3664kb
  • [2024-05-25 16:15:12]
  • 提交

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'