[CodeForce 801A] Vicious Keyboard
题目链接: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的更多相关文章
- AC日记——Vicious Keyboard codeforces 801a
801A - Vicious Keyboard 思路: 水题: 来,上代码: #include <cstdio> #include <cstring> #include < ...
- 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 ...
- 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 ...
- Vicious Keyboard CodeForces - 801A (暴力+模拟)
题目链接 题意: 给定一个字符串,最多更改一个字符,问最多可以有多少个“VK”子串? 思路: 由于数据量很小,不妨尝试暴力写.首先算出不更改任何字符的情况下有多个VK字串,然后尝试每一次更改一个位置的 ...
- 【codeforces 801A】Vicious Keyboard
[题目链接]:http://codeforces.com/contest/801/problem/A [题意] 一个字符串只由VK组成; 让你修改一个字符; 使得剩下的字符串里面子串VK的个数最大; ...
- CodeForces801-A.Vicious Keyboard-暴力
A. Vicious Keyboard time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- 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 ...
- Codeforces Round #409 (rated, Div. 2, based on VK Cup 2017 Round 2) 题解【ABCDE】
A. Vicious Keyboard 题意:给你一个字符串,里面只会包含VK,这两种字符,然后你可以改变一个字符,你要求VK这个字串出现的次数最多. 题解:数据范围很小,暴力枚举改变哪个字符,然后c ...
- 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 ...
随机推荐
- Robot framework selenium driver download
Chrome: https://sites.google.com/a/chromium.org/chromedriver/downloads http://npm.taobao.org/mirrors ...
- HttpServletRequestWrapper
1). why 需要改变从 Servlet 容器 (可能是任何的 Servlet 容器)中传入的 HttpServletRequest 对象的某个行为,该怎么办? 一. 继承 HttpServletR ...
- 设计模式之Proxy(代理)(转)
理解并使用设计模式,能够培养我们良好的面向对象编程习惯,同时在实际应用中,可以如鱼得水,享受游刃有余的乐趣. Proxy是比较有用途的一种模式,而且变种较多,应用场合覆盖从小结构到整个系统的大结构,P ...
- 通过Hive将数据写入到ElasticSearch
我在<使用Hive读取ElasticSearch中的数据>文章中介绍了如何使用Hive读取ElasticSearch中的数据,本文将接着上文继续介绍如何使用Hive将数据写入到Elasti ...
- webService入门理解
最近可能开始要搞关于远程接口调用的玩意儿,所以上网查了一些关于远程调用额东西,其中有很多写得很不错,我把其中的比较好的几个整理一下,整理到一块儿,变成个人的理解写出来. 关于所谓的webService ...
- Porsche Piwis II V14. three hundred and fifty computer software Tester II
Porsche piwis tester 2 Help Devices: SERP automatio tranny, air-conditioner, SRS, ABDOMINAL MUSCLES, ...
- kubernetes install for centos
官方的文档写的很清楚 https://kubernetes.io/docs/getting-started-guides/centos/centos_manual_config/ 如果已经安装过doc ...
- Spring 注入的两种方式
Spring 的两种注入方式: 1. 属性注入:通过无参构造函数+setter方法注入 2. 构造注入:通过有参的构造函数注入. 优缺点: 1. 属性注入直白易懂,缺点是对于属性可选的时候,很多个构造 ...
- 如何解决win10关机状态下,按键盘会自动开机的问题
关机状态下按下键盘会自动开机,是因为所装的系统默认设置了快速启动功能 下面是关闭快速启动的方法: 步骤一: 在win10桌面右击,点击显示设置 步骤二: 电源和睡眠-->其他电源设置 步骤三: ...
- K8S学习笔记之将Google的gcr.io、k8s.gcr.io 换为国内镜像
0x00 添加docker官方的国内镜像 sudo tee /etc/docker/daemon.json <<-'EOF' { "registry-mirrors": ...