超简单题解
2024-03-31 14:44:35
发布于:上海
42阅读
0回复
0点赞
超简单
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main() {
string a,b;
int n,t;
cin>>t;
while (t--){
cin>>n>>b;
a="1";//想要最大开头一定是1
for (int i=1;i<n;i++){
if (b[i]+1!=a[i-1]+b[i-1]-'0'){//如果这一位加1不等于构造出来的上一位 那么这一位的a就是1
a+='1';
}else{//否则就是0
a+='0';
}
}
cout<<a<<endl;
}
return 0;
}
这里空空如也
有帮助,赞一个