https://www.nowcoder.com/acm/contest/143/J
答案无非那么几种,要么都用2,要么都用3,要么3主2补,要么2主3补。
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<iomanip>
using namespace std;
const int maxn = 1e5 + 12;
#define ll long long int
int main() {
ll n, p2, p3, ans, tmp;
scanf("%lld %lld %lld", &n, &p2, &p3);
tmp = min(p2, p3);
ans = min(n / 3 * p3 + (n % 3 ? tmp : 0), n / 2 * p2 + (n % 2 ? tmp : 0));
if (n % 3 == 1) ans = min(ans, (n - 4) / 3 * p3 + 2 * p2);
if (n % 2 == 1) ans = min(ans, (n - 3) / 2 * p2 + p3);
printf("%lld\n", ans);
return 0;
}