acwing 1023 买书 (完全背包求方案数)

题面

在这里插入图片描述

题解

在这里插入图片描述

代码

#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<algorithm>

using namespace std;
const int N = 1010;

int n;
int f[N];
int v[5] = {
    
    0, 10, 20, 50, 100};

int main() {
    
    

    cin >> n;
    f[0] = 1;
    for (int i = 1; i <= 4; i++) {
    
    
        for (int j = v[i]; j <= n; j++) {
    
    
            f[j] += f[j - v[i]];
        }
    }

    cout << f[n] << endl;

    return 0;
}

猜你喜欢

转载自blog.csdn.net/qq_44791484/article/details/115267654