比赛 2026.1.8 评测结果 AAAAAAATTT
题目名称 教练的烦恼 最终得分 70
用户昵称 梦那边的美好CE 运行时间 3.332 s
代码语言 C++ 内存使用 3.73 MiB
提交时间 2026-01-08 20:25:26
显示代码纯文本
#include<bits/stdc++.h>
#define int long long
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define N 200005
#define INF 1e18
using namespace std;

inline void read(int &x){bool neg=false; x=0; char ch=0;while(ch<'0'||ch>'9'){ if(ch=='-') neg=true; ch=getchar(); }while(ch>='0'&&ch<='9'){ x=x*10+(ch-'0'); ch=getchar(); }if(neg) x=-x;}

template<typename T>inline void write(T x){if(x<0) putchar('-'), x=-x;if(x>9) write(x/10);putchar(x%10+'0');}

int n,p,q;
int dp0[N], dp1[N];

signed main(){
	freopen("money.in","r",stdin);freopen("money.out","w",stdout);
    read(n);read(p);read(q);

    dp0[0]=0;dp1[0]=INF;

    fo(i,1,n){
        dp0[i]=dp1[i]=INF;
        fo(x,1,i){
            dp0[i]=min(dp0[i], dp0[i-x]+q*x);
            dp0[i]=min(dp0[i], dp1[i-x]+q*x);
        }
        fo(x,1,i){
            dp1[i]=min(dp1[i], dp0[i-x]+p*x*x);
        }
    }

    write(min(dp0[n], dp1[n]));
    putchar('\n');
    return 0;
}