QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#407517#6823. Coffee Overdosejames1BadCreeperWA 1ms3572kbC++17588b2024-05-08 21:37:372024-05-08 21:37:38

Judging History

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

  • [2024-05-08 21:37:38]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3572kb
  • [2024-05-08 21:37:37]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long i64; 

int n, c; 
i64 solve1(void) {
    i64 x = min(n / c, (c + 1) / 2); 
    return 1ll * n * (n + 1) / 2 + 1ll * c * (c - 1) / 2 * x - 1ll * x * (x - 1) / 2 * c;
}
i64 solve2(void) {
    i64 x = n / (c + 1) + 1; 
    return 1ll * x * n * c - 1ll * x * (x - 1) / 2 * c * (c + 1); 
}
void solve(void) {
    cin >> n >> c; 
    int ans = max(solve1(), solve2());
    cout << ans << "\n"; 
}
int main(void) {
    ios::sync_with_stdio(0); 
    int T; 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: 3572kb

input:

4
1 2
2 1
10 4
172800 172800

output:

2
3
63
-204931072

result:

wrong answer 4th words differ - expected: '29859840000', found: '-204931072'