转载请注明出处:http://www.cnblogs.com/Delostik/p/3553114.html

目前已有【A B C D E】

 

例行吐槽:趴桌子上睡着了

 

A. Genetic Engineering

  http://codeforces.com/contest/391/problem/A

  问最少插入几个字符,使得字符串不存在连续偶数个相同字母。不说什么

  

 1 #include <iostream>
 2 #include <string>
 3 using namespace std;
 4 
 5 string s;
 6 int cnt;
 7 
 8 int main(){
 9     cin>>s;
10     s+=' ';
11     int n=s.size(),i,j;
12     for(i=0;i<n;){
13         for(j=i;j<n;j++)
14             if(s[j]!=s[i]){
15                 if((j-i)%2==0) cnt++;
16                 break;
17             }
18             i=j;
19         }
20     cout<<cnt<<endl;
21 }
View Code

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-24
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-09-02
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案