fork download
  1. #include <bits/stdc++.h>
  2. #define MOD 998244353
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7. int t;
  8. cin >> t;
  9. while (t--) {
  10. int n;
  11. cin >> n;
  12. string a, b;
  13. cin >> a >> b;
  14. long long moves = 0;
  15. for (int i = 0; i < n; i++) {
  16. if (a[i] != b[i]) {
  17. moves = (moves + 1LL * (MOD + 1) / 2) % MOD;
  18. }
  19. }
  20. cout << moves << endl;
  21. }
  22. return 0;
  23. }
Success #stdin #stdout 0.01s 5472KB
stdin
4
1
0
1
2
00
00
4
1000
1110
5
01001
10111
stdout
499122177
0
1
2