PAT甲级(Advanced Level)真题-- 1062 To Buy or Not to Buy

通过:643
提交:1220
通过率:52%


Eva would like to make a string of beads with her favorite colors so she
went to a small shop to buy some beads.

There were many colorful strings of beads. However the owner of the
shop would only sell the strings in whole pieces.

Hence Eva must check whether a string in the shop contains all the
beads she needs. She now comes to you for help:

if the answer is “Yes”, please tell her the number of extra
beads she has to buy; or if the answer is “No”, please tell

her the number of beads missing from the string.

For the sake of simplicity, let’s use the characters in the ranges
[0-9], [a-z], and [A-Z] to represent the colors. For

example, the string “YrR8RrY” is the one that Eva would like
to make. Then the string “ppRYYGrrYBR2258” is okay since it
contains

all the necessary beads with 8 extra ones; yet the string
“ppRYYGrrYB225” is not since there is no black bead and one
less red bead.


输入描述:
Each input file contains one test case. Each case gives in two lines the strings of no more than 1000 beads which belong to the shop
owner and Eva, respectively.


输出描述:
For each test case, print your answer in one line. If the answer is “Yes”, then also output the number of extra beads Eva has to buy; or
if the answer is “No”, then also output the number of beads missing from the string. There must be exactly 1 space between the answer
and the number.


输入例子:
ppRYYGrrYBR2258
YrR8RrY


输出例子:
Yes 8


对于每个测试用例,请将答案打印在一行中。如果答案是“是”,那么还要输出Eva必须购买的额外珠子的数量; 或者
如果答案是“否”,则还输出字符串中缺少的珠子数量。


这道题很简单,python解法如下:

x=input().strip()
y=input().strip()
flag=0
a=set()
count=0
for i in y:a.add(i)
for i in a:if x.count(i)<y.count(i):flag=1count+=y.count(i)-x.count(i)
if flag==1:print("No",count)
else:print("Yes",len(x)-len(y))

PAT甲级(Advanced Level)真题-- 1062 To Buy or Not to Buy相关推荐

  1. PAT甲级(Advanced Level)真题--1046 Sharing

    PAT甲级(Advanced Level)真题–1046 Sharing 通过:648 提交:1138 通过率:56% To store English words, one method is to ...

  2. A1124 Raffle for Weibo Followers(20分)PAT 甲级(Advanced Level) Practice(C++)满分题解【map】

    John got a full mark on PAT. He was so happy that he decided to hold a raffle(抽奖) for his followers ...

  3. PAT乙级(Basic Level)真题--跟奥巴马一起编程(15)

    这道题本身不难,但是题目给的有点不清楚,导致当时做这道题被坑了好久,最后看了别人的解答才知道掉进坑里了. 题目描述 美国总统奥巴马不仅呼吁所有人都学习编程,甚至以身作则编写代码,成为美国历史上首位编写 ...

  4. A1166 Summit(25分)PAT甲级 (Advanced Level) Practice(C++)满分题解【图】

    A summit (峰会) is a meeting of heads of state or government. Arranging the rest areas for the summit ...

  5. 2020年PAT甲级春季考试真题及答案

    1168 Prime Day The above picture is from Sina Weibo, showing May 23rd, 2019 as a very cool "Pri ...

  6. PAT乙级(Basic Level)真题 在霍格沃茨找零钱

    题目描述 如果你是哈利·波特迷,你会知道魔法世界有它自己的货币系统 -- 就如海格告诉哈利的:"十七个银西可(Sickle)兑一个加隆(Galleon),二 十九个纳特(Knut)兑一个西可 ...

  7. PAT乙级(Basic Level)真题-1014 科学计数法 (20)

    科学计数法 (20) 时间限制 1000 ms 内存限制 32768 KB 代码长度限制 100 KB 判断程序 Standard (来自 小小) 题目描述 科学计数法是科学家用来表示很大或很小的数字 ...

  8. 2020年9月PAT甲级满分必备刷题技巧

    2020年7月的考试结束了,除了本次的考题更新,短期内不会更新. [7月题目的特点:首次线上考试,没出链表.树相关的模板题,第2到4题背景新颖,大大降低了抄袭历年代码的可能性,可以看作是线上考试的新趋 ...

  9. 【PAT甲级】A1051-A1100刷题记录

    文章目录 (栈) A1051 Pop Sequence (25 分) 0.47 (静态链表) A1052 Linked List Sorting (25 分) 0.21 (静态树+先根遍历DFS) A ...

最新文章

  1. 这几本高分算法书助你稳步提升
  2. 160个Crackme010
  3. Windows Azure Storage浏览器
  4. 哑编码官方代码自己的注解
  5. python中numpy是什么_什么是NumPy?
  6. Android设计模式之——解释器模式
  7. mysql锁的应用场景_浅谈Mysql共享锁、排他锁、悲观锁、乐观锁及其使用场景
  8. 高效的CSV文本处理利器——univocity-parsers
  9. atitit.seo 发帖关键词以及链接的制作.doc
  10. 使用wps插件,实现word转PDF
  11. 超级记忆/图像数字记忆 110位数字图像转换表 61-70
  12. 需求变更对软件质量的影响
  13. 2021-2022蓝桥杯寒假集训训练 - 问题 G: HTML新の手 -图片收集者
  14. 淘宝买家秀后台操作与各场景展示逻辑
  15. Unity3D制作3维立体小游戏
  16. linux内核计算次方,linux内核bic和cubic实现
  17. 蘑菇书 第一章绪论 习题
  18. 林业调查规划设计资质怎么办理?
  19. matlab找多项式最值,如何利用matlab计算最小多项式
  20. spring boot 配置多个Filter过滤器

热门文章

  1. Python中常用的一些操作总结(未完待续)update @ 2017-5-18
  2. Linux学习(3)-常用命令
  3. iMeta | 南科大宋毅组综述逆境胁迫下植物向微生物组求救的遗传基础(附招聘)
  4. 三峡大学陈迪马:土壤微食物网对全球变化的响应与反馈
  5. 为了你的幸福,你知道细菌有多努力吗?
  6. Removed k rows containing missing values
  7. plotly可视化绘制多坐标轴图
  8. R可视化绘制对数正态分布(Log Normal Distribution)
  9. R探索新数据分析(Exploratory Data Analysis,EDA)
  10. 奇异值分解SVD和偏最小二乘奇异值分解PLSSVD