QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#376692 | #6823. Coffee Overdose | zhulexuan | WA | 0ms | 3696kb | C++14 | 1.5kb | 2024-04-04 15:09:04 | 2024-04-04 15:09:05 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf INT_MAX
#define fr(i,l,r) for (i=(l); i<=(r); i++)
#define rfr(i,l,r) for (i=(l); i>=(r); i--)
template<typename T>inline void read(T &n){
T w=1; n=0; char ch=getchar();
while (!isdigit(ch) && ch!=EOF){ if (ch=='-') w=-1; ch=getchar(); }
while (isdigit(ch) && ch!=EOF){ n=(n<<3)+(n<<1)+(ch&15); ch=getchar(); }
n*=w;
}
template<typename T>inline void write(T x){
if (x==0){ putchar('0'); return ; }
T tmp;
if (x>0) tmp=x;
else tmp=-x;
if (x<0) putchar('-');
char F[105];
long long cnt=0;
while (tmp){
F[++cnt]=tmp%10+48;
tmp/=10;
}
while (cnt) putchar(F[cnt--]);
}
#define Min(x,y) x = min(x,y)
#define Max(x,y) x = max(x,y)
//基础配置=================================================================================
ll n,c;
ll solve1(){
ll x = (c+1)/2;
// Min(x,n/(c+1));//这边不能+1!!!
return n*(n+1)/2 + c*(c-1)/2 * x - x*(x-1)/2 * c;
}
ll solve2(){
ll x = n/(c+1)+1;
return x*n*c - x*(x-1)/2*c*(c+1);
}
void solve(){
read(n); read(c);
// printf("solve1 = %lld\n",solve1());
// printf("solve2 = %lld\n",solve2());
ll ans = max(solve1(),solve2());
write(ans); putchar('\n');
}
int main(){
// freopen("a.in","r",stdin);
// freopen(".out","w",stdout);
ll qt;
read(qt);
while (qt--) solve();
return 0;
}
//g++ a.cpp -o a -Wall -Wl,--stack=512000000
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3696kb
input:
4 1 2 2 1 10 4 172800 172800
output:
2 3 63 644987474006400
result:
wrong answer 4th words differ - expected: '29859840000', found: '644987474006400'