1 条题解

  • 0
    @ 2026-9-30 12:54:32

    C++ :

    
    #include <cstdio>
    int main(){
        int cnt[6], w[6] = {1, 2, 3, 5, 10, 20};
        for(int i = 0; i < 6; i++) if(scanf("%d", &cnt[i]) != 1) cnt[i] = 0;
        static char f[1005];
        f[0] = 1;
        for(int i = 0; i < 6; i++)
            for(int c = 0; c < cnt[i]; c++)
                for(int s = 1000; s >= w[i]; s--)
                    if(f[s - w[i]]) f[s] = 1;
        int ans = 0;
        for(int s = 1; s <= 1000; s++) if(f[s]) ans++;
        printf("%d\n", ans);
        return 0;
    }
    
    
    • 1

    信息

    ID
    2766
    时间
    1000ms
    内存
    256MiB
    难度
    (无)
    标签
    递交数
    0
    已通过
    0
    上传者