题目链接: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. BestCoder Round #55 ($)

    C 构造一个矩阵,然后采用矩阵快速幂 #include <iostream> #include <algorithm> #include <string.h> #i ...

  2. Hive和sparksql中的dayofweek

    dayofweek在hive2.2.0开始支持 ,低版本的hive没有提供原生的dayofweek函数,有时需要用到的时候不甚方便.其实低版本的sparksql和hive中可用以下方式实现dayofw ...

  3. java实现 HTTP/HTTPS请求绕过证书检测代码实现

    java实现 HTTP/HTTPS请求绕过证书检测代码实现 1.开发需求 需要实现在服务端发起HTTP/HTTPS请求,访问其他程序资源. 2.URLConnection和HTTPClient的比较 ...

  4. 1113: No mapping for the Unicode character exists in the target multi-byte code page

    windows版本nginx启动 报错. 启动方式:到nginx所在目录执行:nginx.exe -c conf\nginx.conf 原因:所在路径中含有中文字符. 解决:换个没有中文的路径.

  5. Codeforce 287A - IQ Test (模拟)

    In the city of Ultima Thule job applicants are often offered an IQ test. The test is as follows: the ...

  6. jetbrain_ia

    在激活Jetbrains旗下任意产品的时候选择激活服务器填入以下地址便可成功激活 http://idea.liyang.io 最新方法(2018.3.4) http://blog.csdn.net/w ...

  7. 数据分析之pandas01

    Series 一.Series Series是一种类似于一维数组的对象,有两部分组成:     .values:一组数据(ndarray类型)     .index: 相关的数据索引标签 二.seri ...

  8. Kattis之旅——Inverse Factorial

    题目意思就是已知n的阶乘,求n. 当输入的阶乘小于10位数的时候,我们可以用long long将字符串转化成数字,直接计算. 而当输入的阶乘很大的时候,我们就可以利用位数去大概的估计n. //Asim ...

  9. MySQL&MyBatis 时间处理的配合

    1:Mysql 时间类型 mysql数据库:时间类型 1)datetime datetime: "yyyy-mm-dd hh:mm:ss" datetime "1000- ...

  10. v-bind属性的绑定

    v-bind:属性绑定: 当我们并没有使用v-bind使用的时候,突破不能显示出来,会提示错误,提示我们使用v-bind: 当我们使用v-bind时图片就可以显示: v-bind的简写是冒号: 使用v ...