QOJ.ac

QOJ

حد الوقت: 1.0 s حد الذاكرة: 256 MB مجموع النقاط: 100

#10026. 条件

الإحصائيات

给定一个包含 $n$ 个不同正整数的列表 $a$,一个正整数 $k$,以及一个正整数 $\ell$。请找到大于或等于 $\ell$ 的最小整数 $x$,使得它满足以下三个条件中的恰好一个

  • $x$ 在列表 $a$ 中;
  • $x$ 不能被 $k$ 整除;
  • $x$ 的十进制表示中包含数字 7。

输入格式

第一行包含两个整数 $n$ 和 $k$ ($1 \le n \le 10^5$, $2 \le k \le 10^5$)。 第二行包含 $n$ 个整数 $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10^{18}$)。 第三行包含一个整数 $\ell$ ($1 \le \ell \le 10^{18}$)。

输出格式

输出一个整数,即问题的答案。

样例

输入格式 1

5 9
181 182 184 178 81
173

输出格式 1

183

输入格式 2

1 888
888
888

输出格式 2

888

说明

在样例 1 中,整数 173, 174, 175, 176, 177, 179, 181, 182 满足两个条件。整数 178 满足三个条件。整数 180 不满足任何条件。最后,整数 183 满足恰好一个条件:它不能被 9 整除。

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.