Ankit_132

A

Sep 27th, 2023
267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.63 KB | None | 0 0
  1.  
  2. #include <bits/stdc++.h>
  3.  
  4. using namespace std;
  5.  
  6. #define ll     long long
  7. #define _test   int _TEST; cin>>_TEST; while(_TEST--)
  8.  
  9. int main()
  10. {
  11.     _test
  12.     {
  13.         int n;
  14.         string s;
  15.         cin>>n>>s;
  16.  
  17.         ll int MOD = 1e9 + 7;
  18.  
  19.         ll int ans = 1;
  20.  
  21.         for(int i=0; i+2<=n-1; i+=2)
  22.         {
  23.             ll int x = 0;
  24.  
  25.             int a = (s[i]-'0');
  26.             int b = (s[i+1]-'0');
  27.             int c = (s[i+2]-'0');
  28.  
  29.             x += ((a&b) == c);
  30.             x += ((a|b) == c);
  31.             x += ((a^b) == c);
  32.  
  33.             (ans *= x) %= MOD;
  34.         }
  35.  
  36.         cout<<ans<<"\n";
  37.     }
  38. }
  39.  
Advertisement
Add Comment
Please, Sign In to add comment