#P4369. [Code+#4] 组合数问题

[Code+#4] 组合数问题

Description

As we all know, Xiao Cong is good at calculations, especially at computing binomial coefficients. So Xiao Cong gives you two numbers xx and kk, and wants you to express xx as the sum of exactly kk distinct binomial coefficients. By distinct, we mean that for two binomial coefficients C(n1,m1)C(n_1, m_1) and C(n2,m2)C(n_2, m_2), if n1n2n_1 \neq n_2 or m1m2m_1 \neq m_2, then these two binomial coefficients are considered different. To keep the computation from being too complex, you must ensure that every binomial coefficient C(n,m)C(n, m) you provide satisfies 0mnx0 \leq m \leq n \leq x. It is guaranteed that there is a solution.

Input Format

Read from standard input.

The first line contains two integers x,kx, k.

Output Format

Output to standard output.

Output kk lines. Each line contains two integers n,mn, m representing a binomial coefficient C(n,m)C(n, m). If multiple answers are possible, output any one of them.

6 2
3 1
3 2

Hint

For 20%20\% of the testdata, k=1k = 1.

For another 20%20\% of the testdata, x100x \leq 100.

For another 20%20\% of the testdata, k=2k = 2.

For 100%100\% of the testdata, 1x109,1k1031 \leq x \leq 10^9, 1 \leq k \leq 10^3.

Credit: https://www.luogu.org/discuss/show/38908

Translated by ChatGPT 5