【洛谷-P1909】解题报告(水题)

原始题目

P1909 买铅笔

题目大意

三种笔个数,单价不同,求买超过n支铅笔最少花费。

解题思路

水题

解题代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<string, string> pss;

#define rep(i, a, n) for (int i = a; i < n; ++i)
#define per(i, a, n) for (int i = n - 1; i >= a; --i)
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define mp make_pair
#define pb push_back
#define np next_permutation
#define INF 0x3f3f3f3f
#define EPS 1e-8
#define endl '\n'

int a[10], b[10], n, ans[3], cnt;

int main()
{
ios::sync_with_stdio(false);
while (cin >> n) {
rep(i, 0, 3)
{
cin >> a[i] >> b[i];
ans[i] = ceil(1.0 * n / a[i]) * b[i];
}

int minp = ans[0];
rep(i, 1, 3)
{
if (ans[i] < minp) {
minp = ans[i];
}
}
cout << minp << endl;
}
}

收获与反思