32
查看原帖
32
1286053
Nostopathy楼主2024/4/28 19:11
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,p,q;
void s(){
	cin>>n>>p>>q;
	if(p==0){
		cout<<0<<'\n';
		return ;
	}
	if(n==1){
		cout<<p<<'\n';
		return ;
	}
	int x=(q/p-1)/2;
	int r=n-x,ans;
	if(r%2==1){
		x++,r--;
	}
	ans=x*p,ans+=(x-1)*x*p/2,ans+=(r/2)*q;
	cout<<ans<<'\n';
}
signed main(){
	int t;
	cin>>t;
	while(t--){
		s();
	}
}
2024/4/28 19:11
加载中...