题目链接:http://codeforces.com/problemset/problem/801/A

思路:题目中字符串的长度最长100个字符,所以,可以考虑用暴力,先遍历一遍匹配“VK”的,并把符合条件的标记成其他的字符(如'$'),然后再遍历一遍,只要找到符合"VV"或者"KK"的,就把答案加1,然后跳出循环,然后输出答案即可。

AC代码:

#include<cstdio>
#include<cstring> using namespace std; int main() {
char arr[102];
int cnt;
while (scanf("%s", arr) != EOF) {
cnt = 0;
for (int i = 1; i < strlen(arr); i++) {
if (arr[i - 1] == 'V' && arr[i] == 'K') {
cnt++;
arr[i - 1] = arr[i] = '$';
}
}
for (int i = 0; i < strlen(arr) - 1; i++) {
if (arr[i] == arr[i + 1] && (arr[i] == 'V' || arr[i] == 'K')) {
cnt++;
break;
}
}
printf("%d\n", cnt);
memset(arr, 0, strlen(arr));
}
return 0;
}

[CodeForce 801A] Vicious Keyboard的更多相关文章

  1. AC日记——Vicious Keyboard codeforces 801a

    801A - Vicious Keyboard 思路: 水题: 来,上代码: #include <cstdio> #include <cstring> #include < ...

  2. Codeforces801A Vicious Keyboard 2017-04-19 00:16 241人阅读 评论(0) 收藏

    A. Vicious Keyboard time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  3. Codeforces 801 A.Vicious Keyboard & Jxnu Group Programming Ladder Tournament 2017江西师大新生赛 L1-2.叶神的字符串

    A. Vicious Keyboard time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  4. Vicious Keyboard CodeForces - 801A (暴力+模拟)

    题目链接 题意: 给定一个字符串,最多更改一个字符,问最多可以有多少个“VK”子串? 思路: 由于数据量很小,不妨尝试暴力写.首先算出不更改任何字符的情况下有多个VK字串,然后尝试每一次更改一个位置的 ...

  5. 【codeforces 801A】Vicious Keyboard

    [题目链接]:http://codeforces.com/contest/801/problem/A [题意] 一个字符串只由VK组成; 让你修改一个字符; 使得剩下的字符串里面子串VK的个数最大; ...

  6. CodeForces801-A.Vicious Keyboard-暴力

    A. Vicious Keyboard time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  7. Codeforces Round #409 (rated, Div. 2, based on VK Cup 2017 Round 2)(A.思维题,B.思维题)

    A. Vicious Keyboard time limit per test:2 seconds memory limit per test:256 megabytes input:standard ...

  8. Codeforces Round #409 (rated, Div. 2, based on VK Cup 2017 Round 2) 题解【ABCDE】

    A. Vicious Keyboard 题意:给你一个字符串,里面只会包含VK,这两种字符,然后你可以改变一个字符,你要求VK这个字串出现的次数最多. 题解:数据范围很小,暴力枚举改变哪个字符,然后c ...

  9. Codeforces Round #409 (rated, Div. 2, based on VK Cup 2017 Round 2) A B C D 暴力 水 二分 几何

    A. Vicious Keyboard time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

随机推荐

  1. html5-盒子模型

    /*div{background: green;width: 60%;padding-top: 10px;padding-right: 20px;padding-bottom: 30px;paddin ...

  2. Java多线程-----volatile关键字详解

       volatile原理     Java语言提供了一种稍弱的同步机制,即volatile变量,用来确保将变量的更新操作通知到其他线程.当把变量声明为volatile类型后, 编译器与运行时都会注意 ...

  3. 【函数封装】javascript判断是否是微信浏览器

    //判断是否是微信浏览器的函数 function isWeiXin(){ //window.navigator.userAgent属性包含了浏览器类型.版本.操作系统类型.浏览器引擎类型等信息,这个属 ...

  4. c# 制作弹窗

    1.右键选择添加,添加windows窗体 2.添加第几个窗体这就是Form几 3.具现化  窗口,然后调用       具现化窗口名+ShowDialog  就可以弹出新的窗口 这个功能需要使用,自己 ...

  5. Linux基础命令---切换用户su

    su 临时切换身份到另外一个用户,使用su切换用户之后,不会改变当前的工作目录,但是会改变一些环境变量. 此命令的适用范围:RedHat.RHEL.Ubuntu.CentOS.SUSE.openSUS ...

  6. leaflet:调用arcgis切片地图服务

    var mymap = L.map('mapid').setView([31.59, 120.29], 7); L.tileLayer('http://map.geoq.cn/ArcGIS/rest/ ...

  7. 【linux应用】将一个大文件按行拆分成小文件

    例如将一个BLM.txt文件分成前缀为 BLM_ 的1000个小文件,后缀为系数形式,且后缀为4位数字形式 先利用 wc -l BLM.txt #读出BLM.txt有多少行. 再利用 split 命令 ...

  8. JS笔记—03(DOM编程)

    1. 动态体现:HTML代码加载到浏览器,代码运行后改变文档(DOM树)增删改查节点.例如:ajax(不是新技术,是几个技术的合体js+http后台操作)就是这样的原理 2.js对象(浏览器对象.脚本 ...

  9. Sort aborted Error in MySQL Error Log

    现象 [ERROR] lines containing "Sort aborted" are present in the MySQL error log file. [Warni ...

  10. php 腾讯云 对象存储V5版本 获取返回的上传文件的链接方法

    腾讯云 对象存储V5版本 文档地址:https://github.com/tencentyun/cos-php-sdk-v5 调用简单文件上传方法: 返回数据如下 Array ( [data:prot ...