CF1845A.Forbidden Integer
入门
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given an integer n, which you want to obtain. You have an unlimited supply of every integer from 1 to k, except integer x (there are no integer x at all).
You are allowed to take an arbitrary amount of each of these integers (possibly, zero). Can you make the sum of taken integers equal to n?
If there are multiple answers, print any of them.
给你一个整数 n,你需要恰好得到该值。你拥有从 1 到 k 的每个整数的无限供应量,但整数 x 除外(即完全不提供整数 x)。
你可以任取上述每种整数任意多个(也可以不取)。你能否使所取整数之和恰好等于 n?
如果存在多种方案,请输出任意一种即可。
输入格式
The first line contains a single integer t (1≤t≤100) — the number of testcases.
The only line of each testcase contains three integers n,k and x (1≤x≤k≤n≤100).
第一行包含一个整数 t(1≤t≤100)—— 测试用例的数量。
每个测试用例仅有一行,包含三个整数 n、k 和 x(1≤x≤k≤n≤100)。
输出格式
For each test case, in the first line, print "YES" or "NO" — whether you can take an arbitrary amount of each integer from 1 to k, except integer x, so that their sum is equal to n.
If you can, the second line should contain a single integer m — the total amount of taken integers. The third line should contain m integers — each of them from 1 to k, not equal to x, and their sum is n.
If there are multiple answers, print any of them.
对于每个测试用例,在第一行输出 "YES" 或 "NO" —— 表示你是否能从 1 到 k 的整数中(除整数 x 外)任意选取若干个数(每个数可选取任意多次),使得它们的和等于 n。
如果可以,请在第二行输出一个整数 m —— 表示所选整数的总个数;第三行输出 m 个整数 —— 每个整数均在 1 到 k 之间、且不等于 x,且它们的和为 n。
若存在多个合法答案,输出任意一个即可。
输入输出样例
输入#1
5 10 3 2 5 2 1 4 2 1 7 7 3 6 1 1
输出#1
YES 6 3 1 1 1 1 3 NO YES 2 2 2 YES 1 7 NO
说明/提示
Another possible answer for the first testcase is [3,3,3,1]. Note that you don't have to minimize the amount of taken integers. There also exist other answers.
In the second testcase, you only have an unlimited supply of integer 2. There is no way to get sum 5 using only them.
In the fifth testcase, there are no integers available at all, so you can't get any positive sum.
第一个测试用例的另一个可能答案是 [3,3,3,1]。注意,你无需最小化所选整数的个数。还存在其他答案。
在第二个测试用例中,你仅有无限供应的整数 2。仅使用它们无法得到和为 5。
在第五个测试用例中,完全没有任何可用的整数,因此你无法得到任何正整数和。
输入解题思路,AI测评打分。不知道怎么写?