QOJ.ac

QOJ

时间限制: 1 s 内存限制: 256 MB 总分: 100

#960. 超出輸出限制

统计

我哋都知道,對任何 $0 \le k \le n$,$\binom{n}{k}=\frac{n\cdot(n-1)\cdot\ldots\cdot(n-k+2)\cdot(n-k+1)}{1\cdot2\cdot\ldots\cdot(k-1)\cdot k}$ 都係整數。不過,如果我哋可以提供分子同分母因子之間嘅配對嚟證明,唔係幾好咩?

建立一幅二分圖,兩邊各有 $k$ 個頂點。左邊第 $i$ 個頂點對應分子嘅因子 $n+1-i$,右邊第 $j$ 個頂點對應分母嘅因子 $j$。有邊 $i$—$j$,當且僅當 $j$ 整除 $n+1-i$。如果呢幅二分圖有完美匹配,就稱 $k$ 對 $n$ 係可證明嘅。

畀出 $n$,對每個滿足 $0 \le k \le n$ 嘅 $k$,檢查 $k$ 對 $n$ 係咪可證明。

輸入格式

唯一一行有一個整數 $n$($0 \le n \le 10^{18}$)。

輸出格式

輸出一個長度為 $n+1$、由 0 同 1 組成嘅字串,第 $k+1$ 個字元應該係 1,當且僅當 $k$ 對 $n$ 可證明。

咩話,你覺得咁會超出輸出限制?嗯……好啦,我哋將個字串壓縮。

設 $s_0=$0,$s_1=$1。你可以定義 $s_2,s_3,\ldots,s_t$。字串 $s_i$ 應該係若干個之前定義嘅字串串接而成。形式化噉講,$\forall i\ (2 \le i \le t):\ s_i=s_{j_1}+s_{j_2}+\ldots+s_{j_{k_i}}$,其中 $1 \le k_i$,$\forall r\ (1 \le r \le k_i):\ j_r<i$。字串 $s_t$ 應該係呢題嘅答案。

第一行輸出一個整數 $t$($2 \le t \le 500$)。

之後 $t-1$ 行,輸出 $s_i$ 嘅描述。每份描述應該係 $k_i\ j_1\ j_2\ \ldots\ j_{k_i}$ 嘅形式,滿足 $1 \le k_i$ 同 $0 \le j_r<i$。

所有描述嘅總長度唔可以超過 $10\,000$:$\sum_{i=2}^{t}k_i \le 10\,000$。

可以證明,對所有合法測試,都有方法喺滿足全部限制之下構造出答案字串。如果有多種方法,輸出其中任何一種就得。留意,你唔需要最小化 $t$,亦唔需要最小化所有描述嘅總長度。

樣例

輸入格式 1

1

輸出格式 1

2
2 1 1

輸入格式 2

0

輸出格式 2

2
1 1

輸入格式 3

7

輸出格式 3

4
2 1 1
4 1 2 0 0
3 3 1 2

說明

第三個樣例入面:$s_2=s_1+s_1=$1$+$1$=$11,$s_3=s_1+s_2+s_0+s_0=$1$+$11$+$0$+$0$=$11100,$s_4=s_3+s_1+s_2=$11100$+$1$+$11$=$11100111。

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
#320EditorialOpen题解jianglyView

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.