85pts 求调
查看原帖
85pts 求调
1097314
封禁用户楼主2024/11/11 17:05
#include<bits/stdc++.h>
#define int long long
using namespace std;
int p,q,r;
int len(int x){
	int ans=0;
	while(x){
		x/=10;
		ans++;
	}
	return ans;
}
int fpow(int x,int y){
	int ans=1;
	for(int i=1;i<=y;i++) ans*=x;
	return ans;
}
int sol(int x,int k){
	int l=len(x),t=1,ans=0,p;
	while(x){
		p=fpow(10,len(x)-1);
		ans+=x/p*fpow(k,l-t);
		t++;
		x%=p;
	}
	return ans;
}
signed main(){
	cin>>p>>q>>r;
	for(int i=2;i<=16;i++){
		if(sol(p,i)*sol(q,i)==sol(r,i)){
			cout<<i;
			return 0;
		}
	}
	cout<<0;
}
2024/11/11 17:05
加载中...