比赛 2026.1.8 评测结果 AAAAAAAAAA
题目名称 教练的烦恼 最终得分 100
用户昵称 彭欣越 运行时间 0.036 s
代码语言 C++ 内存使用 3.70 MiB
提交时间 2026-01-08 19:06:10
显示代码纯文本
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=200010;
ll n,p,q,ans=1e18;
ll judge (int x,int y) {
	ll t1=x/y,t2=x%y;
	return p*(y-t2)*t1*t1+p*t2*(t1+1)*(t1+1);
}
int main () {
	freopen("money.in","r",stdin);
	freopen("money.out","w",stdout);
	ios::sync_with_stdio(0);
	cin.tie(0),cout.tie(0);
	cin >> n >> p >> q;
	for (int i=0;i<=n;i++) {
		ans=min(ans,i*q+judge(n-i,i+1));
	}
	cout << ans <<endl;
	return 0;
}