luogu#P8140. [ICPC2020 WF] Trailing Digits

[ICPC2020 WF] Trailing Digits

题目背景

ICPC2020 WF M

题目描述

A large shipment of doodads has just arrived, and each doodad has a suggested retail price of bb cents. You've noticed that consumers are much more likely to purchase goods when most of the trailing digits are the same. For example, items are more likely to be priced at 9999 cents rather than 5757 cents. So to make your goods more appealing, you've decided to sell your goods in bundles. To make a bundle, you choose a positive integer kk, and sell kk doodads for k×bk \times b cents. With an appropriate choice of kk you can have a more pleasing price. For example, selling 5757-cent doodads in bundles of size 77 means that each bundle sells for 399399 cents, which has two trailing 99s, rather than no trailing 99s of 5757. This idea of trailing 99s can be generalized to any other trailing digit: bundles of 692692 5757-cent doodads sell for 3944439\,444 cents (three trailing 44s) and bundles of one million doodads sell for 5700000057\,000\,000 cents (six trailing 00s).

After a little thought, you realize that you do not want to make your bundles too large---not only can the price be excessive, but who really needs several million doodads? For any type of doodad, your marketing department has a maximum bundle price of aa.

Given the price of a doodad, the desired trailing digit, and the maximum price of a bundle, write a program that optimizes the trailing digits.

输入格式

Input consists of a single line containing three integers bb, dd, and aa, where bb (1b<1061 \leq b < 10^{6}) is the price of a doodad in cents, dd (0d90 \leq d \leq 9) is the desired trailing digit, and aa (ba<1010000b \leq a < 10^{10\,000}) is the maximum price of a bundle.

输出格式

Output the maximum number of consecutive occurrences of dd that can appear at the end of a bundle price, given that the price of the bundle cannot exceed aa.

题目大意

题目描述

有一批货,每个价值 bb 元,可以把 nn 个货打包出售,价格是 b×nb \times n 元(前提是b×nab \times n\le a),使末尾含有尽可能多的数字 dd ,求最多的 dd 数量。

输入格式

一行三个整数,bb , ddaa

输出格式

一个整数,最多的 dd 数量。

说明/提示

对于全部数据,有 1b<1061 \le b < 10^6 , 0d90 \le d \le 9 , ba<1010000b \le a < 10^{10000}

57 9 1000
2
57 4 40000
3
57 4 39000
2