70
查看原帖
70
980202
Orange0628楼主2025/6/25 17:00
#include <bits/stdc++.h>
using namespace std;
int p,q,r;
bool check(int b,int x){
	int i=0,a[1005]={0};
	while(x){
		a[++i]=x%b;
		x/=b;
	}
	int xx=0;
	for(int j=i;j>=1;j--){
		xx+=a[j]*pow(10,(--i));
	}
	return xx==r;
}
int main()
{
	cin>>p>>q>>r;
	int pq=p*q;
	for(int i=2;i<=16;i++){
		if(check(i,pq)){
			cout<<i<<endl;
			return 0;
		}
	}
	cout<<0<<endl;
	return 0;
}

玄关!

2025/6/25 17:00
加载中...