QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#212649 | #6823. Coffee Overdose | jiangtaizhe001 | WA | 3ms | 4232kb | C++14 | 1.5kb | 2023-10-13 19:01:40 | 2023-10-13 19:01:40 |
Judging History
answer
#include<cstdio>
#include<iostream>
#define db double
#define pc putchar
#define ll long long
#define Tp template<typename _T>
Tp _T mabs(_T a){ return a<0?-a:a; }
Tp _T mmax(_T a,_T b){ return a<b?b:a; }
Tp _T mmin(_T a,_T b){ return a<b?a:b; }
Tp void mswap(_T &a,_T &b){ _T t=a; a=b; b=t; return; }
using namespace std;
struct IO{
char buf[1<<21],*p1,*p2;
char gc(){ return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++; }
IO & operator >> (char &x){ x=gc(); while(x=='\r'||x=='\n'||x==' ') x=gc(); return *this; }
Tp IO & operator >> (_T &x){
x=0; char c=gc(); bool f=0; while(c<'0'||c>'9'){ if(c=='-') f^=1; c=gc(); }
while('0'<=c&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=gc(); f?x=-x:0; return *this;
}
int st[39],top;
IO & operator << (char x) { pc(x); return *this; }
Tp IO & operator << (_T x){
if(x<0) x=-x,pc('-'); if(x==0){ pc('0'); return *this; }
top=0; while(x) st[++top]=x%10,x/=10;
while(top--) pc(st[top+1]+48); return *this;
}
}fin;
#define maxn
ll s,c,ans,k,l;
void work(){
fin>>s>>c; if(c==1){ fin<<s*(s+1)/2<<'\n'; return; }
if(s<=c-1){ fin<<c*s<<'\n'; return; }
ans=(c-1)*c;
k=(mmin(c*(c+1)/2,s)-(c-1))/(c+1);
l=k*(c+1)+c-1;
ans+=(s+l+1)*(s-l)/2;
ans+=(l+2*c)*k/2*c;
k=(s+c)/(c+1);
ans=mmax(ans,(s+s-(k-1)*(c+1))*k*c/2);
fin<<ans<<'\n';
}
int main(){
#ifdef LOCAL
freopen("1.in","r",stdin);
//freopen(".out","w",stdout);
#endif
int T; fin>>T; while(T--) work(); return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3660kb
input:
4 1 2 2 1 10 4 172800 172800
output:
2 3 63 29859840000
result:
ok 4 tokens
Test #2:
score: -100
Wrong Answer
time: 3ms
memory: 4232kb
input:
100000 1 1 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 21 1 22 1 23 1 24 1 25 1 26 1 27 1 28 1 29 1 30 1 31 1 32 1 33 1 34 1 35 1 36 1 37 1 38 1 39 1 40 1 41 1 42 1 43 1 44 1 45 1 46 1 47 1 48 1 49 1 50 1 51 1 52 1 53 1 54 1 55 1 56 1 57 1 58 1 59 1 60 1 ...
output:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 ...
result:
wrong answer 9006th words differ - expected: '217', found: '216'