AT_abc473_d.Coefficient Stair
普及/提高-
通过率:0%
时间限制:2.00s
内存限制:1024MB
AC君温馨提醒
该题目为【atcoder】题库的题目,您提交的代码将被提交至atcoder进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Output all length-N sequences A=(A1,A2,…,AN) consisting of non-negative integers that satisfy i=1∑Ni×Ai=K, in lexicographic order from smallest to largest.
Here, you will only receive inputs such that the number of sequences satisfying the condition is at most 3×105.
What is lexicographic order for sequences?
A sequence S=(S1,S2,…,S∣S∣) is said to be lexicographically smaller than a sequence T=(T1,T2,…,T∣T∣) if either 1. or 2. below holds. Here, ∣S∣ and ∣T∣ denote the lengths of S and T, respectively.
- ∣S∣<∣T∣ and (S1,S2,…,S∣S∣)=(T1,T2,…,T∣S∣).
- There exists an integer 1≤i≤min{∣S∣,∣T∣} such that both of the following hold.
- (S1,S2,…,Si−1)=(T1,T2,…,Ti−1)
- Si is (numerically) smaller than Ti.
输出所有长度为 N 的非负整数序列 A=(A1,A2,…,AN),满足 i=1∑Ni×Ai=K,并按字典序从小到大排列。
本题保证输入数据满足:满足条件的序列总数不超过 3×105。
什么是序列的字典序?
序列 S=(S1,S2,…,S∣S∣) 被称为字典序小于序列 T=(T1,T2,…,T∣T∣),当且仅当以下条件 1 或 2 成立。其中,∣S∣ 和 ∣T∣ 分别表示序列 S 和 T 的长度。
- ∣S∣<∣T∣,且 (S1,S2,…,S∣S∣)=(T1,T2,…,T∣S∣)。
- 存在整数 1≤i≤min{∣S∣,∣T∣},使得以下两个条件同时成立:
- (S1,S2,…,Si−1)=(T1,T2,…,Ti−1);
- Si(数值上)小于 Ti。
输入格式
The input is given from Standard Input in the following format:
N K
输入从标准输入中以如下格式给出:
N K
输出格式
Let q be the number of sequences of non-negative integers satisfying the condition; output them over q lines. Each line should contain the elements of a sequence of non-negative integers satisfying the condition, in order, separated by spaces. For every sequence, all sequences outputted before it must be lexicographically smaller than it.
设 q 为满足该条件的非负整数序列的个数;将这些序列按行输出,共 q 行。每行应按顺序包含一个满足条件的非负整数序列的各元素,元素之间用空格分隔。对于任意一个序列,所有在它之前输出的序列都必须字典序小于它。
输入输出样例
输入#1
3 8
输出#1
0 1 2 0 4 0 1 2 1 2 0 2 2 3 0 3 1 1 4 2 0 5 0 1 6 1 0 8 0 0
输入#2
1 200000
输出#2
200000
输入#3
8 9
输出#3
0 0 0 1 1 0 0 0 0 0 1 0 0 1 0 0 0 0 3 0 0 0 0 0 0 1 0 0 0 0 1 0 0 1 1 1 0 0 0 0 0 2 0 0 1 0 0 0 0 3 1 0 0 0 0 0 1 0 0 0 0 0 0 1 1 0 0 2 0 0 0 0 1 0 1 0 1 0 0 0 1 1 0 0 0 1 0 0 1 1 2 0 0 0 0 0 1 2 0 1 0 0 0 0 1 4 0 0 0 0 0 0 2 0 0 0 0 0 1 0 2 0 1 1 0 0 0 0 2 1 0 0 1 0 0 0 2 2 1 0 0 0 0 0 3 0 0 0 0 1 0 0 3 0 2 0 0 0 0 0 3 1 0 1 0 0 0 0 3 3 0 0 0 0 0 0 4 0 0 0 1 0 0 0 4 1 1 0 0 0 0 0 5 0 0 1 0 0 0 0 5 2 0 0 0 0 0 0 6 0 1 0 0 0 0 0 7 1 0 0 0 0 0 0 9 0 0 0 0 0 0 0
说明/提示
Sample 1 Explanation:
For example, for the sequence (0,1,2) we have 0×1+1×2+2×3=0+2+6=8, so it satisfies the condition. There is no sequence satisfying the condition that is lexicographically smaller than this one, so output 0 1 2 on the first line.
Including (0,1,2), ten sequences satisfy the condition. Output these in lexicographic order from smallest to largest.
Constraints
- 1≤N≤10
- 1≤K≤2×105
- The number of sequences satisfying the condition is at most 3×105.
- All input values are integers.
样例 1 解释:
例如,对于序列 (0,1,2),有 0×1+1×2+2×3=0+2+6=8,因此它满足条件。不存在字典序比该序列更小且满足条件的序列,故第一行输出 0 1 2。
包括 (0,1,2) 在内,共有十个序列满足条件。请将这些序列按字典序从小到大输出。
限制条件
- 1≤N≤10
- 1≤K≤2×105
- 满足条件的序列个数至多为 3×105。
- 所有输入值均为整数。
输入解题思路,AI测评打分。不知道怎么写?