QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 1024 MB Total points: 100

#2172. 末尾数字

Statistics

有一大批小玩意儿刚刚到货,每个小玩意儿的建议零售价为 $b$ 分。你注意到,当商品价格末尾的数字大部分相同时,消费者购买的可能性会大大增加。例如,商品定价为 99 分比 57 分更容易被购买。因此,为了让你的商品更具吸引力,你决定将商品打包出售。为了制作一个包裹,你选择一个正整数 $k$,并以 $k \times b$ 分的价格出售 $k$ 个小玩意儿。通过选择合适的 $k$,你可以得到一个更令人满意的价格。例如,将 57 分的小玩意儿以 7 个为一组打包,意味着每个包裹售价 399 分,末尾有两个 9,而 57 分则没有末尾的 9。这种末尾数字的想法可以推广到任何其他数字:692 个 57 分的小玩意儿打包售价为 39 444 分(末尾有三个 4),而一百万个小玩意儿打包售价为 57 000 000 分(末尾有六个 0)。

经过一番思考,你意识到你不想让包裹太大——不仅价格可能过高,而且谁真的需要几百万个小玩意儿呢?对于任何类型的小玩意儿,你的市场部门都有一个包裹最高限价 $a$。

给定一个小玩意儿的价格、期望的末尾数字以及包裹的最高限价,编写一个程序来优化末尾数字。

输入格式

输入包含一行,由三个整数 $b$、$d$ 和 $a$ 组成,其中 $b$ ($1 \le b < 10^6$) 是一个小玩意儿的价格(单位:分),$d$ ($0 \le d \le 9$) 是期望的末尾数字,$a$ ($b \le a < 10^{10\,000}$) 是包裹的最高限价。

输出格式

输出在包裹价格不超过 $a$ 的前提下,包裹价格末尾能出现的连续 $d$ 的最大个数。

样例

样例输入 1

57 9 1000

样例输出 1

2

样例输入 2

57 4 40000

样例输出 2

3

样例输入 3

57 4 39000

样例输出 3

2

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.