90分求助
查看原帖
90分求助
855093
0x00AC3375楼主2023/7/3 19:33
#include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
using namespace std;

long long base2dec(char* number, int base)
{
	long long total=0LL;
	int l=strlen(number);
	for(int i=0;i<=l-1;i+=1) total+=(number[i]-48)*pow(base,l-1-i);
	return total;
}

int main()
{
	char a[10],b[10],c[10];
	cin>>a>>b>>c;
	for(int B=2;B<=16;B+=1)
	{
		if(base2dec(a,B)*base2dec(b,B)==base2dec(c,B))
		{
			cout<<B;
			exit(0);
		}
	}
	cout<<0;
}

WA on #8 and #17

2023/7/3 19:33
加载中...