QOJ.ac

QOJ

时间限制: 1.0 s 内存限制: 256 MB 总分: 100 可 Hack ✓

#10204. 异端的……莫比乌斯

统计

Rikka 在学校里好奇地四处走动,直到一个门牌号为 404 的奇怪房间引起了她的注意。

这看起来像是一个计算机房——里面整齐地摆放着几十台电脑,但到处都是纸张、钢笔和白板,营造出一种紧张的氛围。突然,Rikka 在一台电脑上发现了一些神秘的代码,看起来与其他的没什么不同——这难道是来自内心世界的讯息吗?

兴奋的 Rikka 开始了她的探索。这段讯息是由一个名为 for_patterns_in_mobius 的程序生成的,它输出了一个长度为 $10^9$ 的字符串 $s$,其中依次包含了 $x = 1, 2, \dots, 10^9$ 的 $|\mu(x)|$ 的值。

突然,Rikka 听到了外面的脚步声。她迅速拍了一张截图并离开了。截图记录了一个长度为 200 的字符串 $t$,它可能是 $s$ 的一个子串。现在 Rikka 想知道它是否真的是 $s$ 的子串,如果是,它在 $s$ 中第一次出现的位置在哪里。

你能帮她破译这些代码吗?

输入格式

总共有 10 行。每行包含 20 个字符,每个字符要么是 "0",要么是 "1"。$t$ 是将它们按顺序连接起来的结果。

输出格式

在唯一的一行中输出一个整数。如果 $t$ 是 $s$ 的子串,输出它在 $s$ 中第一次出现的位置,即满足对于所有的 $i = 0, 1, \dots, 199$,数字 $|\mu(p + i)|$ 构成的字符串正好是 $t$ 的最小正整数 $p$。否则输出 $-1$。

样例

样例输入 1

11101110011011101010
11100100111011101110
11100110001010101110
11001110111011001110
01101110101011101000
11101110111011100110
01100010111011001110
11101100101001101110
10101110010011001110
11101110011011101010

样例输出 1

1

样例输入 2

01010101010101010101
10101010101010101010
01010101010101010101
10101010101010101010
01010101010101010101
10101010101010101010
01010101010101010101
10101010101010101010
01010101010101010101
10101010101010101010

样例输出 2

-1

说明

$\mu()$ 的定义如下:

对于任何正整数 $x$,设 $x = \prod_{i=1}^k p_i^{c_i}$ 为 $x$ 的唯一分解,其中 $p_i$ 是互不相同的质数,$c_i$ 是正整数,若 $x = 1$ 则 $k = 0$。因此,$\mu(x)$ 定义为:

$$\mu(x) = \begin{cases} 0 & \exists c_i > 1 \\ (-1)^k & \text{其他情况} \end{cases}$$

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.