链接:https://codeforces.com/problemset/problem/328/B

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.

Input

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.

Output

Print the required number of instances.

Examples

input

Copy

42
23454

output

Copy

2

input

Copy

169
12118999

output

Copy

1

Note

This problem contains very weak pretests.

代码:

#include<cstdio>
#include<iostream>
#include<cstring>
#include<map>
#include<queue>
#include<algorithm>
#include<cstdlib>
using namespace std;
long long t,g,r,n;
char a[1001];
int b[1001];
map<int,int>m,p;
int main()
{cin>>t;cin>>a;n=strlen(a);for(int i=0;i<n;i++){b[i+1]=a[i]-'0';m[b[i+1]]++;}int min1=1000;while(t){int x=t%10;t/=10;p[x]++;}for(int i=0;i<=9;i++){if(p[i]!=0){if(i==2||i==5)min1=min(min1,(m[2]+m[5])/(p[2]+p[5]));else if(i==9||i==6)min1=min(min1,(m[6]+m[9])/(p[6]+p[9]));elsemin1=min(min1,m[i]/p[i]);}}cout<<min1;return 0;
}

B. Sheldon and Ice Pieces相关推荐

  1. 2013/7/16 HNU_训练赛4

    CF328B Sheldon and Ice Pieces 题意:给定一个数字序列,问后面的数字元素能够组成最多的组数. 分析:把2和5,6和9看作是一个元素,然后求出一个最小的组数就可以了. #in ...

  2. 跟sheldon学习时间管理

    (本文转自温泉老师的博客|学生的时间管理与自我提高|CandyApe|,话说温泉老师是我们来自豆瓣的一位好友买家,从他这篇文章充分印证了古人"淫者见淫,智者见智"的理论-- 平日最 ...

  3. 如何使用(免费软件)Microsoft ICE轻松扫描大图片

    Scanning pics is a big enough pain, but oversize images can be a nightmare. Today, we'll look at som ...

  4. ICE BOX 配置,使用----第一篇

    一 理论部分 (1) 为什么要使用icebox? icebox server代替了通常的server. icebox是为了方便集中管理多个ice服务而建立的. 它通过使用icebox服务器,把ice服 ...

  5. 英特尔第三代 Ice Lake 发布正面与 AMD EPYC PK,结果令人大跌眼镜!

    作者 | 夕颜 出品 | AI科技大本营(ID:rgznai100) 导读:传闻已久的第三代英特尔至强可扩展处理器,终于在北京风光最美的4月份发布了. 北京时间4月7日晚,在著名的网红打卡地,百年老首 ...

  6. ICE专题:ICE起步

    ICE初步 最早开始接触ICE是在2005,3月份,当时一个朋友向另一个正打算研究corba的朋友强烈的推荐了ICE. 参考:http://www.zeroc.com/ 1.什么是ICE? ICE(i ...

  7. 模型的可解释性:部分依赖图PDP和个体条件期望图ICE

    来源:Deephub Imba 本文约1800字,建议阅读5分钟 本文我们通过一个简单据集的回归示例了解了部分依赖图 (PDP) 和个体条件期望 (ICE) 图是什么,以及如何在 Python 中制作 ...

  8. 配置C++和C#开发ICE环境

    2019独角兽企业重金招聘Python工程师标准>>> C++配置环境 1.设置编译工具路径和配置编译命令: #编译命令,如果有多个文件就执行多次slice2cpp.exe命令 se ...

  9. Ice “Hello World”的实现

    2019独角兽企业重金招聘Python工程师标准>>> Ice简介: Ice (Internet Communications Engine),是一种面向对象的中间件平台,既然是平台 ...

最新文章

  1. 查找字符位置_学习VB编程第69天 字符串查找与替换
  2. BZOJ2286 : [Sdoi2011]消耗战
  3. 交互设计软件 html,交互设计工具篇
  4. mysql5.7 undo_MySQL 5.7新特性之在線收縮undo表空間
  5. Windows环境下32位汇编语言程序设计笔记-基础篇
  6. 7-11 求链式线性表的倒数第K项 (20 分)
  7. 使用librosa库对音频信号进行采样以及分帧处理
  8. html 超链接 中文转码,html和Url转码与解码
  9. ICLR 2022 语言模型驱动的语义分割算法:Language-Driven Semantic Segmentation
  10. was 部署php,was 配置web服务器
  11. cba篮球暂停次数和时间_CBA在比赛时,为什么有“官方暂停”?
  12. 假装自己升级了Win11~
  13. 第六章:详细设计。盒图、问题分析图即PAD图、过程设计语言PDL伪码
  14. 通过用jQuery写一个页面,我学到了什么
  15. macOS安装软件./configuredmake
  16. Python爬取美女主播图片适合初学者
  17. alicloud linux3安装Jdk和Maven
  18. Android IPC 机制详解:IBinder
  19. 进程间通信: 进程间通信都有哪些方法?
  20. 【大熊智能nrf connect使用方法

热门文章

  1. 【以太网硬件九】1000base-X是什么?
  2. [object HTMLDivElement] 创建dom报与 innerHTML appendChild使用
  3. 图(有向图、无向图)
  4. matlab中长整数表示,matlab – 整数的因式分解
  5. Noble - Window平台NodeJs蓝牙BLE开发库
  6. 如何在linux服务器下载文件夹,linux服务器怎么下载文件到本地
  7. RXD、TXD你接错了没?
  8. 微积分知识点回顾与总结(八):重积分
  9. 米赛尔java火_山地自行车推荐 这几款山地自行车值得入手
  10. js运动小球碰壁反弹