25分,求助!!!
查看原帖
25分,求助!!!
1652416
shenyuanzaiqi楼主2025/6/22 15:12

只有25分,能帮忙看看吗?

#include<bits/stdc++.h>
using namespace std;
long long n,k,t,s,f,h,b[2000],c[20][5];
string a[5],x;
int main() {
	cin>>a[1]>>a[2]>>a[3];
	for(int i=2;i<=16;i++){
		for(int j=1;j<=3;j++){	
			k=i;x=a[j];
			h=x.size()-1;
			for(int r=0;r<=h;r++){
				b[r]=int(x[r]-48);
			}
			t=1;
			s=0;
			f=1;
			for(int r=h;r>=0;r--){
				if(b[r]>=i){
					f=0;
				}
				s+=t*b[r];
				t*=k;
			}
			if(f==0){
				c[i][j]=-10;
			}
			else{
				c[i][j]=s;
			}
		}
	}
	for(int i=2;i<=16;i++){
		if(c[i][1]*c[i][2]==c[i][3]){
			cout<<i;
			return 0;
		}
	}
	return 0;
}
2025/6/22 15:12
加载中...