https://ac.nowcoder.com/acm/problem/219035
cpp
#include <iostream>
using namespace std;
long long typedef LL;
LL fun(LL n, LL a, LL b) {
if (n <= 2) return min(a, b);
LL ret = 0;
if (a * 3 < b * 2) // 尽可能选择双人船
{
ret += n / 2 * a;
n %= 2;
if(n) ret += min(min(a, b), b - a);
}
else // 尽可能选择三人船
{
ret += n / 3 * b;
n %= 3;
if (n == 1) ret += min(min(a, b), 2*a - b);
else if (n == 2) ret += min(min(a, b), 3*a - b);
}
return ret;
}
int main()
{
int t;
cin >> t;
while (t--) {
LL n, a, b;
cin >> n >> a >> b;
cout << fun(n, a, b) << endl;
}
return 0;
}