题解 | #邮票#
邮票
https://www.nowcoder.com/practice/b6735b1bd4ff488fb9a9032457410f66
#include <iostream>
using namespace std;
#define max 8 * 5 + 10 * 4 + 18 * 6 //最大邮资数(单位:角)
int main() {
int count[max + 1] = {0}; //统计每种邮资可能情况数
for (int i = 0; i <= 5; i++)
for (int j = 0; j <= 4; j++)
for (int k = 0; k <= 6; k++) {
int value = 8 * i + 10 * j + 18 * k; //邮资值(单位:角)
if (value != 0)count[value]++;
}
int num = 0; //邮资种数
for (int i = 1; i <= max; i++)
if (count[i] > 0)
num++; //邮资值存在,邮资种数增1
cout << num;
}