题干:

Tonio has a keyboard with only two letters, "V" and "K".

One day, he has typed out a string s with only these two letters. He really likes it when the string "VK" appears, so he wishes to change at most one letter in the string (or do no changes) to maximize the number of occurrences of that string. Compute the maximum number of times "VK" can appear as a substring (i. e. a letter "K" right after a letter "V") in the resulting string.

Input

The first line will contain a string s consisting only of uppercase English letters "V" and "K" with length not less than 1 and not greater than 100.

Output

Output a single integer, the maximum number of times "VK" can appear as a substring of the given string after changing at most one character.

Examples

Input
VK

Output
1

Input
VV

Output
1

Input
V

Output
0

Input
VKKKKKKKKKVVVVVVVVVK

Output
3

Input
KVKV

Output
1

题目大意:给你一个字符串,改其中一个字母或者不改,然后让你从中找有几个VK。

解题报告:     思维题啊,找几组数据测试一下就找出规律来了,就是先去掉VK的(记录下来ans个),然后看有没有VV或者KK,有的话就输出ans+1,没有的话就输出ans

ac代码:

#include<iostream>
#include<cstdio>
#include<cstring>using namespace std;const int N = 100 + 5;
char a[N];
bool bk[N];
int ans = 0, flag = 0;
int main()
{cin>>a;int len = strlen(a);for(int i = 0; i < len; i++) {if(a[i] == 'V' && a[i + 1] == 'K') {ans++;bk[i]=1;bk[i+1]=1;}}for(int i = 0; i < len; i++) {if(bk[i]==0&&bk[i+1]==0&&a[i]==a[i + 1]) flag=1;}if(flag==1) ans++;printf("%d\n", ans);return 0 ;
}

【CF#801 A.】 Vicious Keyboard(字符串查找,水题)相关推荐

  1. [双指针] aw3333. K-优字符串(双指针+水题)

    文章目录 1. 题目来源 2. 题目解析 1. 题目来源 链接:3333. K-优字符串 2. 题目解析 双指针水题. 可发现首尾对应位置均独立,且得分可以任意变换.故仅需统计初始得分 sum,最小操 ...

  2. codeforces 1038a(找最长的前k个字母出现相同次数的字符串)水题

    http://codeforces.com/problemset/problem/1038/A(题目链接) You are given a string s of length n, which co ...

  3. AcWing每日一题 3333.K-优字符串(水题)

    K-优字符串 原题链接 Charles 将一个字符串的优良分数定义为,在 1≤i≤N/2 的范围内,满足 Si≠SN−i+1 的 i 的数量(索引从 1 开始). 例如,字符串 CABABC 的优良分 ...

  4. 【CodeForces - 122B 】Lucky Substring (字符串,水题)

    题干: Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decima ...

  5. hdu 2629 Identity Card (字符串解析模拟题)

    这题是一个字符串模拟水题,给12级学弟学妹们找找自信的,嘿嘿; 题目意思就是要你讲身份证的上的省份和生日解析出来输出就可以了: http://acm.hdu.edu.cn/showproblem.ph ...

  6. Coderforces 字符串水题合集

    今天我们聊聊 Coderforces 字符串水题合集. 字符串就是string. 这是string的百度翻译,我们要谈的是画框的.↓ string是C++.java.VB等编程语言中的字符串,字符串是 ...

  7. hdu 2025:查找最大元素(水题,顺序查找)

    查找最大元素 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Sub ...

  8. cmd html 查找汉子字,字符串查找 cmd find命令

    字符串查找 cmd find命令 2009-07-05 14:33:02 作者: 当我要查找字符串的时候,第一个想到的命令,并不是我在本文中要讲解的find,而是比它更强悍的命令findstr. 我对 ...

  9. python3 字符串查找 效率比较

    Python中字符串查找方式有多种,常见的有re.match/search or str.find 用一个例子来说明各种方式的效率如下: from timeit import timeit impor ...

  10. python字符串find函数-python字符串查找函数的用法详解

    python字符串查找函数的使用 打开Python开发工具IDLE,新建"findstr.py'文件,并写代码如下: s ='/ab/bx,.s' print (s.find('/x')) ...

最新文章

  1. Python程序设计题解【蓝桥杯官网题库】 DAY5-基础练习
  2. php-mysql管理利器 adminer
  3. Java注释 link_开源代码中注释中的那些a link p @ 是给什么编辑器用的????
  4. Python的弱引用
  5. [刨根问底] 五分钟搞懂组合评价模型—模糊Borda (以2021 年大学生数模国赛C题为例)
  6. Redis问的太深入,面试官说:“你先回去等通知吧“!
  7. DATEDIFF() 函数返回两个日期之间的天数
  8. oracle 简单job
  9. Visual Studio Code鼠标右键Open in Browser消失问题
  10. Monkey Test
  11. 树莓派红外避障小车python_制作树莓派wifi遥控和自动避障小车
  12. 仿腾讯QQ空间登录的css代码
  13. win的反义词_小学英语常用近义词、反义词、同音词汇总 ~~~ 赶紧转给孩子
  14. Devexpress TreeList控件支持拼音首字母查询
  15. scrapy 引擎,调度器出入队列及去重原理及几个构造request方法
  16. 优秀后端架构师必会知识:史上最全MySQL大表优化方案总结...
  17. CDN-内容推送网络
  18. 金融基础知识笔记(一)
  19. 查看windows系统和office是否永久激活(转载)
  20. 直击|咪蒙、才华有限青年注销 旗下公众号清空或停更

热门文章

  1. [剑指offer]面试题第[49]题[Leetcode][第264题][JAVA][丑数][动态规划][堆]
  2. php对话框制作,织梦系统“提示窗口对话框类”详解,oxwindow.class.php、catalog_do.php...
  3. mysql 循环体 如何测试_mysql里如何循环插入数据,进行测试
  4. 初中位似图形作图_[如何画位似图形] 位似图形的画法及步骤
  5. 求无序序列每个元素最接近的值
  6. ahp层次分析法_基于层次分析法(AHP)的店铺选址应用研究
  7. 磁盘剩余空间策略_MySQL磁盘消耗迅猛掌握这点就够了,包你事半功倍
  8. 编译mediastreamer2/ffmpeg/linphone(x86平台)
  9. Linux 定时器设置
  10. java如何添加进程_如何创建一个进程,如何进程调用进程