求助!为什么re3个点?
查看原帖
求助!为什么re3个点?
797897
_QyGyQ_楼主2023/8/5 12:04
#include<bits/stdc++.h>
using namespace std;
const int N=1e9+7;
using ll=unsigned long long;
bool a[N];
ll two_(string s){
	return stoi(s,nullptr,2);
}
ll three_(string s){
	return stoi(s,nullptr,3);
}
void twoA(string s){
	char bt;
	for(int i=1;i<=s.size()-1;i++){
		bt=s[i];
		if(s[i]=='0'){
			s[i]='1';
			a[two_(s)]=true;
		}
		else{
			s[i]='0';
			a[two_(s)]=true;
		}
		s[i]=bt;
	}
}
ll threeA(string s){
	char bt;
	for(int i=0;i<=s.size()-1;i++){
		bt=s[i];
		if(s[i]=='0'){
			s[i]='1';
			if(a[three_(s)]==true) return three_(s);
			s[i]='2';
			if(a[three_(s)]==true) return three_(s);
		}
		else if(s[i]=='1'){
			s[i]='0';
			if(a[three_(s)]==true) return three_(s);
			s[i]='2';
			if(a[three_(s)]==true) return three_(s);
		}
		else{
			s[i]='0';
			if(a[three_(s)]==true) return three_(s);
			s[i]='1';
			if(a[three_(s)]==true) return three_(s);
		}
		s[i]=bt;
	}
}
int main(){
	string two,three;
	cin>>two;
	cin>>three;
	twoA(two);
	cout<<threeA(three);
	return 0;
}
2023/8/5 12:04
加载中...