Thief in a Shop n个物品每个价值ai,要求选k个,可以重复.问能取到哪几个价值? 1 ≤ n, k ≤ 1000,1 ≤ ai ≤ 1000 题解 将选一个物品能取到的价值的01生成函数k次方即可得到选k个物品得到的某个权值的方案数. 出题人卡NTT模数,998244353和1004535809都会被卡.然而469762049没被卡-- CO int N=1048576; int a[N]; int rev[N],omg[N]; void NTT(int a[],int lim)…
题目大意:有一个小偷,拿$k$个东西,有$n$种产品,每种产品都有无限多个.对于每个第$i$ 种产品,它的价值是$A_i$.可能偷走的物品价值之和. 题解:对于所有的物品构造生成函数$F(x)=\sum\limits_{i\in A}x^i$,取$k$个物品相当于取其中的$k$项相乘,输出$F^k(x)$中不为零的项就行了.(这道题模数$998244353$和$1004535809$都被$hack$了,看$Weng\_weijie\;dalao$的题解得双模数没被卡,于是就$A$了)(这道题似乎…
E. Thief in a Shop time limit per test 5 seconds memory limit per test 512 megabytes input standard input output standard output A thief made his way to a shop. As usual he has his lucky knapsack with him. The knapsack can contain k objects. There ar…
题目链接 E. Thief in a Shop time limit per test 5 seconds memory limit per test 512 megabytes input standard input output standard output A thief made his way to a shop. As usual he has his lucky knapsack with him. The knapsack can contain k objects. The…
C - Thief in a Shop 思路 :严格的控制好k的这个数量,这就是个裸完全背包问题.(复杂度最极端会到1e9) 他们随意原来随意组合的方案,与他们都减去 最小的 一个 a[ i ] 组合的方案数目是不会改变的 那么我们就 dp [ i ]表示 i 这个价格需要的最少 个数.  这样求最小个数保证不会漏解 然后 如果这个  i 能通过 1 - k 个物品组合出来,那么 一定能通过k 个物品组合出 i + k * a [ 1 ]. #include<bits/stdc++.h> us…
E - Thief in a Shop 题目大意:给你n ( n <= 1000)个物品每个物品的价值为ai (ai <= 1000),你只能恰好取k个物品,问你能组成哪些价值. 思路:我们很容易能够想到dp[ i ][ j ]表示取i次j是否存在,但是复杂度1e12肯定不行. 我们将ai排序,每个值都减去a[1]然后再用dp[ i ]表示到达i这个值最少需要取几次,只需要1e9就能完成, 我们扫一遍dp数组,如果dp[ i ]  <= k 则说明 i + k * a[1]是能取到的.…
E. Thief in a Shop 题目连接: http://www.codeforces.com/contest/632/problem/E Description A thief made his way to a shop. As usual he has his lucky knapsack with him. The knapsack can contain k objects. There are n kinds of products in the shop and an inf…
E. Thief in a Shop   A thief made his way to a shop. As usual he has his lucky knapsack with him. The knapsack can contain k objects. There are n kinds of products in the shop and an infinite number of products of each kind. The cost of one product o…
A thief made his way to a shop. As usual he has his lucky knapsack with him. The knapsack can contain k objects. There are n kinds of products in the shop and an infinite number of products of each kind. The cost of one product of kind i is ai. The t…
题目 Source http://codeforces.com/contest/632/problem/E Description A thief made his way to a shop. As usual he has his lucky knapsack with him. The knapsack can contain k objects. There are n kinds of products in the shop and an infinite number of pro…