A. Vicious Keyboard Codeforce

Delphi中使用FireDAC与uniDAC高效连接PostgreSQL的实战指南 本文为Delphi开发者提供了使用FireDAC与uniDAC组件高效连接PostgreSQL数据库的实战指南。文章详细对比了两款组件的选择策略,重点解析了驱动依赖(libpq.dll)的配置、连接参数设置、常见错误排查及性能优化技巧,旨在帮助开发者快速构建稳定可靠的数据库连接。 阅读详情

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

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
Note

For the first case, we do not change any letters. "VK" appears once, which is the maximum number of times it could appear.

For the second case, we can change the second character from a "V" to a "K". This will give us the string "VK". This has one occurrence of the string "VK" as a substring.

For the fourth case, we can change the fourth character from a "K" to a "V". This will give us the string "VKKVKKKKKKVVVVVVVVVK". This has three occurrences of the string "VK" as a substring. We can check no other moves can give us strictly more occurrences.


数据不大,直接暴力


Ac code:

#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <map>
using namespace std;
#define LL long long
#define INF 0x3f3f3f3f
#define fi first
#define se second
#define eps 1

const int maxn=200000+500;



int main() {  
	char s[105]; int vis[105];
	while(~scanf("%s",s)){
		
		memset(vis,0,sizeof vis);
		int cnt=0;
		int len=strlen(s);
		for(int i=0;i<len-1;i++){
			if(s[i]=='V'&&s[i+1]=='K'){
				cnt++;
				vis[i]=vis[i+1]=1;
				i++;
			}
		}
		for(int i=0;i<len-1;i++){
			if((s[i]=='V'||s[i+1]=='K')&&vis[i]==0&&vis[i+1]==0){
				cnt++;
				break;
			}
		}
		printf("%d\n",cnt );
	}
	return 0;
} 



基于Simulink的BCH码编解码仿真建模示例 BCH码是一类循环码,能够纠正一定数量的随机错误。灵活性:可以根据需要选择不同的码长和纠错能力。高效性:适用于短码长和中等码长的场景,广泛用于卫星通信、存储系统等。实现简单:编码和解码过程可以通过硬件或软件高效实现。在本示例中,我们将使用MATLAB/Simulink中的和模块来完成BCH码的编解码操作,并通过仿真验证其误码率(BER)性能。通过本指南,我们介绍了如何基于Simulink搭建一个BCH码的编解码模型,并进行了仿真以验证其性能。背景介绍:理解BCH码的基本原理及其在通信系统中的应用。 阅读详情

相关推荐

使用-flat.vmdk文件恢复ESXI虚拟机的vmdk文件

解决flat.vmdk文件丢失恢复问题

神秘人的博客 6772

Vicious Keyboard

 Vicious Keyboard  CodeForces - 801A  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 "...

C++的星空 407

ARM SMMUv3设备树配置实战:从零开始为RK3588搭建IOMMU环境

本文详细介绍了在RK3588平台上配置ARM SMMUv3设备树的实战经验。从理解硬件架构、设备树节点定义,到内核驱动集成与调试,提供了完整的IOMMU环境搭建指南,并分享了解决StreamID冲突、中断配置等常见问题的技巧,帮助开发者高效完成控制器初始化。

l3m4n的博客 884

Codeforces801A Vicious Keyboard

A. Vicious Keyboard time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Tonio has a keyboard with only two lett

Jelly_acm的博客 988

SDRAM控制器——添加读写FIFO

用FIFO实现数据缓存

H19981118的博客 2627

单片机通识之UART通信协议(如何用汇编实现)

使用汇编实现UART通信

smart_num_1的博客 996

A. Vicious Keyboard

A. Vicious Keyboard time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output Tonio has a keyboard with only two letters, “V” and “K”.One day, he ha

Irish_Moonshine的博客 381

CATIA二次开发核心技术:多实体零件自动化拆解与装配生成深度解析(零件转产品)

CATIA二次开发核心技术:多实体零件自动化拆解与装配生成深度解析

KE17RS的博客 2145

CF - 801A. Vicious Keyboard - 思维

1.题目描述: A. Vicious Keyboard time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Tonio has a keyb

终有绿洲摇曳在沙漠 670

【PostgreSQL教程】PostgreSQL 特别篇之 语言接口Java

本篇教程的Java程序中开始使用PostgreSQL之前,需要确保在计算机上设置了PostgreSQL JDBC和Java。您可以检查Java教程以在计算机上安装Java。现在让本篇教程检查如何设置PostgreSQL JDBC驱动程序。

No8g攻城狮的博客 1756

使用python中pypower进行电力潮流计算

使用python中pypower进行电力潮流计算

总裁余(余登武)博客 4862

[CodeForce 801A] Vicious Keyboard

[CodeForce 801A] Vicious Keyboard 题目链接:http://codeforces.com/problemset/problem/801/A 思路:题目中字符串的长度最长100个字符,所以,可以考虑用暴力,先遍历一遍匹配“VK”的,并把符合条件的标记成其他的字符(如'$'),然后再遍历一遍,只要找到符合"VV"或者"K...

Youpeng 128

innovus:streamOut gds中pg text带有冒号(:)解决办法

streamOut后查看layout,发现部分PG text后面加了冒号,比如VDD: / VSS:。当然,这个问题还有另一种解决办法,就是通过脚本给terminal打text再streamOut。我正在「拾陆楼」和朋友们讨论有趣的话题,你⼀起来吧?

m0_61544122的博客 1190

CodeForces 801A Vicious Keyboard

题意:一个只含有'v'和'k'的字符串,最多可以转换一个字符,求含"vk"子串最多的个数。 链接:http://codeforces.com/problemset/problem/801/A 思路:第一遍遍历,查找"vk",并替换成其余字符。第二遍遍历查找"vv"或"kk",并替换。 注意点:无 # When Who Problem Lang

luminous11的专栏 647

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

codeforces 801A Vicious Keyboard

题目链接:http://codeforces.com/contest/801/problem/A 题意:给你一个由字符V和K组成的字符串,问你最多改变一个字符,求字符串中最多出现多少个"VK"; 分析:我是直接扫一遍求出字符串目前有多少"VK",并把它们变成其他字符,例如"00",然后再扫一遍找有没有两个连续的V或者K,有的话输出+1; AC代码: 1 #include<b...

weixin_34174105的博客 90

android 蓝牙通讯demo

android 下蓝牙通讯demo,实现了发现蓝牙,使能蓝牙,通过蓝牙发送消息。

【CodeForces】【水题】【暴力】801 A Vicious Keyboard

【题目】http://codeforces.com/problemset/problem/801/A 【题意】一个字符串中只有V和K现在最多更改其中一个字母(可能不改),问更改后最多能出现多少个"VK"? 【思路】统计已经出现过的VK,将这些位置标记,再扫一遍如果遇到VV或者KK并且两个位置都没有被标记过,ans++,接着break 【代码】 #include&lt;bits/stdc+...

swqeaaa的博客 277

ssm框架搭建

这个是一个在idea上成功跑起来的ssm框架项目,保存在这里方便以后使用直接下载

CodeForces - 801A

CodeForces - 801A Vicious Keyboard 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” ap...

mandiheyanyu的博客 223

Codeforces 801A 暴力 string

传送门:题目 题意: 给一个字符串,里面只有VK字母,计算所有出现VK的次数,你有且只有一次转换的机会,可以把V转成K,或者把K转成V,你可以不使用这次机会。 题解: 题目很水,先统计一次VK的个数,然后再统计一下VV或者KK的个数,如果有,结果+1就好,当时写了20多行,赛后看题解,发现题解Perl只用了一行,C++算头文件只用了5行,用了string.find()方法,很方便。 AC...

shadandeajian的博客 261

水题

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 mos...

jude的博客 212

训练一

一、A - Vicious Keyboard Tonio has a keyboard with only two letters, "V" and "K". One day, he has typed out a stringswith only these two letters. He really likes it when the string "VK" appears, so ...

qq_42569807的博客 269

信息学奥赛一本通 1618:越狱

快速幂

脚踏实地,仰望星空 414

Codeforces 888C:Dominant Character

Dominant CharacterProblem DescriptionYou are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each substring of s with length at least k contains this chara...

Rem_little_fan_boy的博客 392

Codeforces Round #409 Div. 2(A+B)

A. Vicious Keyboard time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output Tonio has a keyboard with only two letters, “V” and “K”.One day, he ha

妍恐龙的博客....^~^眼熟我 1005
上一篇: A. Carrot Cakes Codeforce 思维
下一篇: Valued Keys- Codeforce
GDUFE_SSS
博客等级 码龄9年 1粉丝 60原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值