Advertisement
ec1117

Untitled

Feb 13th, 2022
1,164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.33 KB | None | 0 0
  1. #include "bits/stdc++.h"
  2.  
  3. using namespace std;
  4.  
  5. int main(){
  6.     int n;cin>>n;
  7.     string a,b;
  8.     cin>>a>>b;
  9.  
  10.     int diff[n];
  11.     for(int i=0;i<n;i++){
  12.         if(a[i]==b[i]) diff[i]=0;
  13.         else diff[i]=1;
  14.     }
  15.  
  16.     int cnt=0;
  17.     for(int i=0;i<n;i++){
  18.         if(diff[i]==1){
  19.             if(i==0 || diff[i-1]==0){
  20.                 cnt++;
  21.             }
  22.         }
  23.     }
  24.     cout<<cnt<<endl;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement