QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#376669#6823. Coffee OverdosezhulexuanWA 1ms3488kbC++141.4kb2024-04-04 14:57:262024-04-04 14:57:27

Judging History

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

  • [2024-04-08 20:49:53]
  • hack成功,自动添加数据
  • (/hack/589)
  • [2024-04-04 14:57:27]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3488kb
  • [2024-04-04 14:57:26]
  • 提交

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 = 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

詳細信息

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3488kb

input:

4
1 2
2 1
10 4
172800 172800

output:

2
3
105
29859840000

result:

wrong answer 3rd words differ - expected: '63', found: '105'