QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#376668 | #6823. Coffee Overdose | zhulexuan | WA | 0ms | 3616kb | C++14 | 1.4kb | 2024-04-04 14:56:55 | 2024-04-04 14:56:56 |
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+1);
}
void solve(){
read(n); read(c);
ll ans = min(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
詳細信息
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3616kb
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'