CF328B.Sheldon and Ice Pieces
普及/提高-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Do you remember how Kai constructed the word "eternity" using pieces of ice as components?
Little Sheldon plays with pieces of ice, each piece has exactly one digit between 0 and 9. He wants to construct his favourite number t. He realized that digits 6 and 9 are very similar, so he can rotate piece of ice with 6 to use as 9 (and vice versa). Similary, 2 and 5 work the same. There is no other pair of digits with similar effect. He called this effect "Digital Mimicry".
Sheldon favourite number is t. He wants to have as many instances of t as possible. How many instances he can construct using the given sequence of ice pieces. He can use any piece at most once.
你还记得凯是如何用冰块作为组件拼出单词“eternity”(永恒)的吗?
小谢尔顿正在玩一些冰块,每块冰上恰好刻有一个数字,范围是 0 到 9。他想拼出自己最喜爱的数字 t。他发现数字 6 和 9 非常相似,因此可以将刻有 6 的冰块旋转后当作 9 使用(反之亦然)。类似地,2 和 5 也可以互相替代。除此之外,没有其他数字对具有这种效果。他将这种现象称为“数字拟态”(Digital Mimicry)。
谢尔顿最喜爱的数字是 t。他希望尽可能多地拼出 t 的副本。给定一串冰块,他最多能拼出多少个 t?每块冰最多只能使用一次。
输入格式
The first line contains integer t (1 ≤ t ≤ 10000). The second line contains the sequence of digits on the pieces. The length of line is equal to the number of pieces and between 1 and 200, inclusive. It contains digits between 0 and 9.
第一行包含一个整数 t(1≤t≤10000)。第二行包含拼图块上的数字序列。该行的长度等于拼图块的数量,且在 1 到 200(含)之间。其中只包含数字 0 到 9。
输出格式
Print the required number of instances.
打印所需数量的实例。
输入输出样例
输入#1
42 23454
输出#1
2
输入#2
169 12118999
输出#2
1
说明/提示
This problem contains very weak pretests.
本题的预测试数据非常弱。
输入解题思路,AI测评打分。不知道怎么写?