edu9E. Thief in a Shop】的更多相关文章

题意:n个物品每个价值a[i],要求选k个,可以重复,问能取到哪几个价值 题解:fft裸题.但是直接一次fft,然后快速幂会boom.这样是严格的\(2^{20}*log2(2^{20})*log(w)\).需要在快速幂里fft,每次取最大的2的次幂,然后fft也boom了,不知道是不是写搓了.ntt过了..... //#pragma GCC optimize(2) //#pragma GCC optimize(3) //#pragma GCC optimize(4) //#pragma GCC…
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…
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)…
题目 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…
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…