Rockethon 2014 problem A - Genetic Engineering solution :
#include <iostream> #include <cstdio> #include <cstring> using namespace std; int main() { int cnt, r; char s[105], c; scanf("%s\n", s); c=s[0]; cnt=1; r=0; for(int i=1; i<strlen(s); i++) { if(s[i]!=c) { if(cnt%2==0) r++; cnt=1; c=s[i]; } else cnt++; } if(cnt%2==0) r++; printf("%d\n", r); return 0; }
No comments:
Post a Comment