2018牛客多校05 J plan(数学,规律) 发表于 2018-08-02 | 更新于 2019-04-11 | 分类于 题解 , 2018牛客多校 | 评论数: | 阅读次数: 链接:https://www.nowcoder.com/acm/contest/143/J n个人住宾馆,双人间价格为p2,三人间价格为p3,如何安排,使总花费最少。 列方程,枚举最近的6个结果即可。 123456789101112131415161718#include <bits/stdc++.h>using namespace std; using LL = long long;LL n, a, b; signed main() { // freopen("in", "r", stdin); while(~scanf("%lld%lld%lld",&n,&a,&b)) { LL ret = 1e18; for(LL i = 0; i <= 6; i++) { ret = min(ret, (n+1-i)/2*a+(i+2)/3*b); ret = min(ret, (n+2-i)/3*b+(i+1)/2*a); } printf("%lld\n", ret); } return 0;}