QOJ.ac

QOJ

時間限制: 1 s 記憶體限制: 512 MB 總分: 100 难度: [顯示]

#1260. 硬核字符串计数 2

统计

“Hardcore String Counting 1” 发生了什么?那是个秘密!

如果一个字母表上的非空单词 $v$ 可以表示为 $v = ww$(其中 $w$ 为某个单词),则称其为平方串(square)。

如果一个单词的所有非空子串都不是平方串,则称该单词为无平方串(square-free)。

你的任务是计算对于每个从 $1$ 到 $n$ 的 $\ell$,字母表 $\{\mathtt{a}, \mathtt{b}, \mathtt{c}\}$ 上长度为 $\ell$ 的无平方串的数量。

输入仅包含一行,为一个整数 $n$ ($1 \le n \le 120$)。

对于每个从 $1$ 到 $n$ 的 $\ell$,在单独的一行中输出字母表 $\{\mathtt{a}, \mathtt{b}, \mathtt{c}\}$ 上长度为 $\ell$ 的无平方串的数量。

样例

输入格式 1

10

输出格式 1

3
6
12
18
30
42
60
78
108
144

说明

你可以查看 https://oeis.org/A006156 以获取更多详细信息,但这可能对你帮助不大。

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.