#携程笔试# 水果组合题在自己电脑上运行结果是对的,提交出现了EOF when reading a line错误。有人知道原因嘛?
a=input().split(',')
b = [[item.count('a'), item.count('p')] for item in a]
m = int(input())
n = int(input())
def dp(index, m, n):
if m <= 0 or n <= 0 or index < 0:
return 0
res = dp(index-1, m, n)
if b[index][0] <= m and b[index][1] <= n:
res = max(res, dp(index-1, m-b[index][0], n-b[index][1])+1)
return res
print(dp(len(b)-1, m, n))
a=input().split(',')
b = [[item.count('a'), item.count('p')] for item in a]
m = int(input())
n = int(input())
def dp(index, m, n):
if m <= 0 or n <= 0 or index < 0:
return 0
res = dp(index-1, m, n)
if b[index][0] <= m and b[index][1] <= n:
res = max(res, dp(index-1, m-b[index][0], n-b[index][1])+1)
return res
print(dp(len(b)-1, m, n))
全部评论
while true:
xxxxxxxxxxxxxxx
except:
break
这样的格式写
相关推荐
点赞 评论 收藏
分享
点赞 评论 收藏
分享
10-30 18:20
第一拖拉机制造厂拖拉机学院 C++
牛客41406533...:回答他在课上学,一辈子待在学校的老教授用三十年前的祖传PPT一字一句的讲解,使用谭浩强红皮书作为教材在devc++里面敲出a+++++a的瞬间爆出114514个编译错误来学 点赞 评论 收藏
分享