解法:
显然[l,r]之间满足的个数为r-l+1
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define endl '\n'
void solve() {
int n; cin >> n;
string a, b;
cin >> a >> b;
long long cnt = 0, sum = 0;
for (int i = 0; i < n; i++) {
if (a[i] == '1' && b[i] == '1') {
cnt++;
}
else {
cnt = 0;
}
sum += cnt;
}
cout << sum << endl;
return;
}
int main()
{
int t; cin >> t;
while (t--) {
solve();
}
return 0;
}