提交时间:2022-08-01 11:37:34

运行 ID: 54359

#include <bits/stdc++.h> using namespace std; typedef unsigned long long ull; const int MXN = 405; const ull INF = 0x3f3f3f3f3f3f3f3fllu; ull dp[MXN][MXN][MXN]; ull N, M, K, A, B; int main() { // freopen("cure.in", "r", stdin); // freopen("cure.out", "w", stdout); scanf("%llu%llu%llu%llu%llu", &N, &M, &K, &A, &B); for (int i(0); i <= N; ++i) for (int j(0); j <= M; ++j) for (int k(0); k <= K; ++k) dp[i][j][k] = INF; for (int i(0); i <= N; ++i) dp[i][0][0] = 0; for (int i(1); i <= N; ++i) for (int j(1); j <= M; ++j) for (int k(0); k <= K; ++k) { for (int n(1); n <= j; ++n) { int c(k * 1.0 / n + 1); for (int x(0); x <= c; ++x) { dp[i][j][k] = min(dp[i][j][k], dp[i - 1][j - n][max(k - n * x, 0)] + n * A * x * x + B * n * n * x * x); } } } printf("%llu\n", dp[N][M][K]); return 0; }