https://i0.wp.com/eblogarithm.com/wp-content/uploads/2017/07/Codeforces-Round-409-rated-Div-2-based-on-VK-Cup-2017-Round-2-problem-A-Vicious-Keyboard-Solution-In-CC.png?fit=640%2C360

Codeforces Round #409 (rated, Div. 2, based on VK Cup 2017 Round 2), problem: (A) Vicious Keyboard Solution In C/C++

#include <stdio.h>
int ans,l,i;
int main()
{
char ch[110];
scanf(“%s”,ch);
for( ; ch[i+1]; i++)
{
l++;
if(ch[i]==’V’ && ch[i+1]==’K’)
ans++,ch[i]=’#’,ch[i+1]=’#’,i++;
}
l++;
for(i=0; ch[i+1]; i++)
{
if((ch[i]==’V’ && ch[i+1]==’V’) || (ch[i]==’K’&&ch[i+1]==’K’))
{
ans++;
break;
}
}

printf(“%d”,ans);
}

(Visited 11 times, 1 visits today)



There are no comments

Add yours

Leave a Reply

%d bloggers like this: