海阔凭鱼跃,天高任鸟飞。
——宋·阮阅《诗话总龟前集》
一、题目
传送门https://www.luogu.com.cn/problem/P3741
二、代码
input()
s = list(input().strip())
ans = "".join(s).count("VK")
for i in range(len(s)):
if s[i]=='V':
s[i] = 'K'
ans = max(ans,"".join(s).count("VK"))
s[i] = 'V'
elif s[i]=='K':
s[i] = 'V'
ans = max(ans,"".join(s).count("VK"))
s[i] = 'K'
print(ans)
注:该题数据量很小,直接暴力
标签:count,洛谷,Python,max,VK,ans,join,P3741 From: https://blog.csdn.net/2301_78161072/article/details/143090500