Klothes
Time limit1sMemory limit512 MB
Given n, s, k, decide whether k distinct prices from 1 to n can sum to s, and if so print one such subset as a bit string.
- Level
Medium6 of 10
- Topics
- Greedy, Math, Implementation, Combinatorics
- Solved
- No attempts yet
Problem
What an unsmurfy day! Smurfette just found out that someone (probably Jokey Smurf) has stolen all of her clothes and she'll need to buy new ones. There are sets of clothes in the shop each having different integer price from to smurfcoins. Since smurfiness of an article of clothing is proportional to its price Smurfette wants to spend all of her smurfcoins. However her wardrobe will fit only clothes so she needs to buy exactly (having empty places in a wardrobe is bad for her image).
Input
First line of input file contains the number of testcases (). Each testcase consists of a single line containing three integers , , and (, ). is the number of clothes available in the shop, is the number of clothes Smurfette wants to buy, and is the amount of smurfcoins she wants to spend.
Output
For each testcase output on a single line the word "YES" (without quotes) if it is possible to buy clothes so that their price is , or "NO" otherwise. If the answer is "YES" then on the following line output a string of digits . should be if Smurfette should buy article of clothing with price , otherwise should be .