第二个点WA,求助
查看原帖
第二个点WA,求助
946590
Happy_sheep楼主2023/3/22 16:39
#include<bits/stdc++.h>
using namespace std;
string ans="0000000000000000000000000000000000000000000000000000000000000000000000";
int _,n,x,y;
int main(){
	cin>>_;
	while(_--){
		cin>>n;
		ans="00000000000000000000000000000000000000000000000000000000000000000000000";
		for(int i=1; i<=n; i++){
			scanf("%d",&x);
			if(x==1) ans='0'+ans;
			else{
				scanf("%d",&y);
				int t=0;
				while(y){
					ans[t]+=y%2;
					if(ans[t]>='2'){
						ans[t]-=2;
						ans[t+1]++;
					}
					t++;
					y/=2;
				}
			}
		}
		for(int i=0; i<ans.size(); i++){
			while(ans[i]>='2'){
				ans[i]-=2;
				ans[i+1]++;
			}
		}
		int t=1;
		for(int i=ans.size()-1; i>=0; i--){
			if(ans[i]!='0') t=0;
			if(!t) printf("%c",ans[i]);
		}
		if(t==1) cout<<0;
		cout<<'\n';
	}
	return 0;
}
2023/3/22 16:39
加载中...