题解

1 条题解

  • 0
    @ 2020-09-13 10:49:51

    #include<bits/stdc++.h>
    using namespace std;
    const int N = 1e5 + 5;
    struct node{
    int c[6], d[6], n, s;
    long long f[N], ans;
    void main(){
    scanf("%d %d %d %d %d", &c[1], &c[2], &c[3], &c[4], &n);
    f[0] = 1;
    for(int i = 1; i <= 4; i ++){
    for(int j = 0; j <= N - c[i]; j ++){
    f[j + c[i]] += f[j];
    }
    }
    while(n --){
    ans = 0;
    for(int i = 1; i <= 4; i ++){
    scanf("%d", &d[i]);
    }
    scanf("%d", &s);
    ans = f[s];
    for(int i = 1; i <= 4; i ++){
    if(s - (d[i] + 1) * c[i] >= 0){
    ans -= f[s - (d[i] + 1) * c[i]];
    }
    }
    for(int i = 1; i <= 4; i ++){
    for(int j = i + 1; j <= 4; j ++){
    if(s - ((d[i] + 1) * c[i] + (d[j] + 1) * c[j]) >= 0){
    ans += f[s - ((d[i] + 1) * c[i] + (d[j] + 1) * c[j])];
    }
    }
    }
    for(int i = 1; i <= 4; i ++){
    for(int j = i + 1; j <= 4; j ++){
    for(int z = j + 1; z <= 4; z ++){
    if(s - ((d[i] + 1) * c[i] + (d[j] + 1) * c[j] + (d[z] + 1) * c[z]) >= 0){
    ans -= f[s - ((d[i] + 1) * c[i] + (d[j] + 1) * c[j] + (d[z] + 1) * c[z])];
    }

    }
    }
    }
    if(s - ((d[1] + 1) * c[1] + (d[2] + 1) * c[2] + (d[3] + 1) * c[3] + (d[4] + 1) * c[4]) >= 0){
    ans += f[s - ((d[1] + 1) * c[1] + (d[2] + 1) * c[2] + (d[3] + 1) * c[3] + (d[4] + 1) * c[4])];
    }

    printf("%lld\n", ans);

    }
    }
    }Coin;
    int main(){
    Coin.main();
    return 0;
    }

  • 1

信息

难度
9
分类
(无)
标签
递交数
8
已通过
5
通过率
62%
上传者