QOJ.ac

QOJ

Time Limit: 4 s Memory Limit: 262144 MB Total points: 100

#13120. 香蕉桑布卡

Statistics

给定一个由数字组成的字符串 $s$ 和一个质数 $K$。定义字符串 $w$ 为无穷多个 $s$ 的拼接(即 $w := s + s + s + \dots$)。你的任务是找到最小的非负整数,使得该整数是 $K$ 的倍数,且其十进制表示是 $w$ 的一个子串;如果不存在这样的数,则输出 $-1$。

第一行包含一个非空字符串 $s$,其长度不超过 $4 \cdot 10^5$ 位。 第二行包含一个质数 $K$ ($1 \le K \le 4 \cdot 10^5$)。

输出一行,包含一个整数:问题的答案(不含前导零);如果不存在,则输出 $-1$。

样例

输入格式 1

74
3

输出格式 1

474

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.