传送门 题意简述:有四种面值的硬币,现在qqq次询问(q≤1000)(q\le1000)(q≤1000),每次给出四种硬币的使用上限问最后刚好凑出sss块钱的方案数(s≤100000)(s\le100000)(s≤100000). 思路:先跑完全背包预处理出所有硬币都无限制时候的答案. 然后每次询问的时候枚举容斥掉多算的情况即可. 代码: #include<bits/stdc++.h> using namespace std; long long tot,c[5],d[5],s,dp[1000…
当然是容斥啦. 用dp预处理出\( f[i] \),表示在\( i \)价格时不考虑限制的方案数,转移方程是\( f[i]+=f[i-c[j]] \),用状压枚举不满足的状态容斥一下即可. #include<iostream> #include<cstdio> using namespace std; const long long N=100005; long long c[10],T,d[10],s,f[N],ans; long long read() { long long…