QaQ_本地不过
查看原帖
QaQ_本地不过
1286053
Nostopathy楼主2024/4/28 18:56
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
int n,p,q,t;
inline int r1(){
	int x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-48;ch=getchar();}
	return x*f;
}
inline int r2(int i){
	return (n-2*i+1)*(n-2*i)/2*p+i*q;
}
signed main(){
	t=r1();
	while(t--){
		n=r1(),p=r1(),q=r1();
		int l=0,r=n/2,m;
		while(l<r){
			m=(l+r)>>1;
			if(m-1>=0&&r2(m-1)<r2(m))r=m-1;
			else if(m+1<=n&&r2(m-1)<r2(m))l=m+1;
			else l=r-m;
		}
		cout<<r2(l)<<'\n';
	}
}

2024/4/28 18:56
加载中...