85分 求助T.T #1、14、16WA
查看原帖
85分 求助T.T #1、14、16WA
1229793
YuMenXianDou楼主2024/4/3 09:18
#include<stdio.h>
int main(){
	long long int p,q,r;
	scanf("%lld %lld %lld",&p,&q,&r);
	int t,ti,i,j = 0,j1 = 0,j2 = 0;
	int num[10],num1[10],num2[10];
	for (;r;r/=10){
		num[j] = r%10;
		j++;
	}
	for (;p;p/=10){
		num1[j1] = p%10;
		j1++;
	}
	for (;q;q/=10){
		num2[j2] = q%10;
		j2++;
	}
	for (ti = 2;;){
		for (t=0;t<j;t++){
			if (ti <= num[t]){
				ti++;
			}
		}
		for (t=0;t<j1;t++){
			if (ti <= num1[t]){
				ti++;
			}
		}
		for (t=0;t<j2;t++){
			if (ti <= num2[t]){
				ti++;
			}
		}
		break;
	}
	int sum = 0,sum1 = 0,sum2 = 0;
	for (i=ti;i<=16;i++){
		sum = 0;sum1 = 0;sum2 = 0;
		int temp = 1;
		for (t=0;t<j;t++){
			sum += num[t]*temp;
			temp*=i;
		}
		int temp1 = 1;
		for (t=0;t<j1;t++){
			sum1 += num1[t]*temp1;
			temp1*=i;
		}
		int temp2 = 1;
		for (t=0;t<j2;t++){
			sum2 += num2[t]*temp2;
			temp2*=i;
		}
		if (sum1*sum2 == sum){
			printf("%d",i);
			ti = 1;
			break;
		}
	}
	if (ti != 1){
		printf("0");
	}
	return 0;
} 
2024/4/3 09:18
加载中...