303265: CF632E. Thief in a Shop

Memory Limit:512 MB Time Limit:5 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Thief in a Shop

题意翻译

# 题目描述 有一个小偷进入了一个商店。 像平常一样,他把他的幸运背包带在身上,他的背包里能放 k 个东西。商店里有 n 种产品,每种产品都有无限多个。对于每个第 i 种产品,它的价值是 a[i] 。 小偷很贪婪,所以他会准确地拿 k 个产品(他有可能把某一种产品拿很多个)。 你需要找出所有小偷可能偷走的物品价值之和。 ## 输入输出格式 ### 输入格式: 第一行有两个整数 n 和 k(1<=n,k<=1000)—— 物品的数量和小偷会拿的物品数量。 第二行有 n 个整数,每一个 a[i](1<=a[i]<=1000) 是从第 1 个到第 n 个物品的价值。 ### 输出格式: 输出一行,所有可能的被偷窃的物品的价值,每两个之间用一个空格分隔。输出应该以一个递增序列输出。 ## 输入输出样例 ### 输入样例#1: 3 2 1 2 3 ### 输出样例#1: 2 3 4 5 6 ### 输入样例#2: 5 5 1 1 1 1 1 ### 输出样例#2: 5 ### 输入样例#3: 3 3 3 5 11 ### 输出样例#3: 9 11 13 15 17 19 21 25 27 33 翻译贡献者UID:41262

题目描述

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 $ a_{i} $ . The thief is greedy, so he will take exactly $ k $ products (it's possible for some kinds to take several products of that kind). Find all the possible total costs of products the thief can nick into his knapsack.

输入输出格式

输入格式


The first line contains two integers $ n $ and $ k $ ( $ 1<=n,k<=1000 $ ) — the number of kinds of products and the number of products the thief will take. The second line contains $ n $ integers $ a_{i} $ ( $ 1<=a_{i}<=1000 $ ) — the costs of products for kinds from $ 1 $ to $ n $ .

输出格式


Print the only line with all the possible total costs of stolen products, separated by a space. The numbers should be printed in the ascending order.

输入输出样例

输入样例 #1

3 2
1 2 3

输出样例 #1

2 3 4 5 6

输入样例 #2

5 5
1 1 1 1 1

输出样例 #2

5

输入样例 #3

3 3
3 5 11

输出样例 #3

9 11 13 15 17 19 21 25 27 33

Input

题意翻译

# 题目描述 有一个小偷进入了一个商店。 像平常一样,他把他的幸运背包带在身上,他的背包里能放 k 个东西。商店里有 n 种产品,每种产品都有无限多个。对于每个第 i 种产品,它的价值是 a[i] 。 小偷很贪婪,所以他会准确地拿 k 个产品(他有可能把某一种产品拿很多个)。 你需要找出所有小偷可能偷走的物品价值之和。 ## 输入输出格式 ### 输入格式: 第一行有两个整数 n 和 k(1<=n,k<=1000)—— 物品的数量和小偷会拿的物品数量。 第二行有 n 个整数,每一个 a[i](1<=a[i]<=1000) 是从第 1 个到第 n 个物品的价值。 ### 输出格式: 输出一行,所有可能的被偷窃的物品的价值,每两个之间用一个空格分隔。输出应该以一个递增序列输出。 ## 输入输出样例 ### 输入样例#1: 3 2 1 2 3 ### 输出样例#1: 2 3 4 5 6 ### 输入样例#2: 5 5 1 1 1 1 1 ### 输出样例#2: 5 ### 输入样例#3: 3 3 3 5 11 ### 输出样例#3: 9 11 13 15 17 19 21 25 27 33 翻译贡献者UID:41262

加入题单

算法标签: