跳到正文

题解

AT_tkppc4_1_c tj

_colin1112_约 1 分钟
原文
文章信息与版本

文章信息

收录
2025年12月12日
更新
2025年12月12日
篇幅
约 1 分钟

版本

  1. v1当前

思路

不难发现,这是一道判断进制的题。

我们只需枚举 22 到 1010 的进制,判断有没有一样的就行了。

tips:数据范围:101810^{18},要开 long long。


AC Code:

C++
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'

using namespace std;
const int E=1e6+114514;
ll n;
string d;
char test[E]={"0123456789"};
string zhuanhuan(ll x,ll a){
	string arr;
	while(x){
		arr+=test[x%a];
		x/=a;
	}
	reverse(arr.begin(), arr.end());
	return arr;
}
int main(){
	cin >>n>>d;
	for(int i=2;i<=10;i++){
		if(zhuanhuan(n,i)==d){
			cout <<i<<endl;
			return 0;
		}
	}
	return 0;
}
原文