Advertisement
Josif_tepe

Untitled

Feb 17th, 2024
631
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.57 KB | None | 0 0
  1. #include <iostream>
  2. //#include <bits/stdc++.h>
  3. using namespace std;
  4.  
  5.  
  6. int main()
  7. {
  8.     string niza;
  9.     cin>>niza;
  10.     int counter=0;
  11.     for(int i=0; i<niza.size(); i++){
  12.         if(niza[i]=='Y'){
  13.             for(int j=i; j<niza.size(); j += i + 1){
  14.                     if(niza[j]=='Y'){
  15.                         niza[j]='N';
  16.                     }
  17.                     else if(niza[j]=='N'){
  18.                         niza[j]='Y';
  19.                     }
  20.                
  21.             }
  22.             counter++;
  23.         }
  24.     }
  25.     cout<<counter;
  26.     return 0;
  27. }
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement