#P1329. 数列

    ID: 326 远端评测题 1000ms 128MiB 尝试: 0 已通过: 0 难度: 6 上传者: 标签>数学福建省历届夏令营Special JudgeO2优化

数列

Description

There is a sequence a1,a2,,ana_1, a_2, \cdots, a_n, where a1=0a_{1} = 0, and for any term aia_i it holds that aiai+1=1|a_i - a_{i+1}| = 1 (1i<n1 \le i < n). Let $s = \sum_{i = 1}^n a_i = a_{1} + a_{2} + \cdots + a_{n}$ denote the sum of the first nn terms.

Given the length nn and the sum ss of the first nn terms, do the following:

  • Output the total number of sequences that satisfy the conditions, modulo 2642^{64}.
  • Output up to 100100 sequences that satisfy the conditions (if fewer than 100100 exist, output all of them).

Input Format

The input contains a single line with two integers, the sequence length nn and the sum ss.

Output Format

This problem uses a Special Judge.

On the first line, output a single integer tt, the total number of valid sequences modulo 2642^{64}.

Then output several lines, each containing nn integers, describing one valid sequence.

4 0

2
0 -1 0 1
0 1 0 -1

Hint

  • Constraints

    For all testdata, it is guaranteed that 1n1001 \le n \le 100, 263s<263-2^{63} \le s < 2^{63}.

  • Notes

    Special Judge provider:

    user/230249

Translated by ChatGPT 5