【JZOJ】【数论】YY

题意

给出一个 S S ,求一个 N N 使得 N N N= S S

样例

输入

387420489

输出

9

思路

根据换底公式求出NN的位数,然后判断

代码

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
using namespace std;
string s;
unsigned long long i;
int main()
{
	freopen("yy.in","r",stdin);
	freopen("yy.out","w",stdout);
	cin>>s;
	for (i=1;i<=s.size();i++)
		if (floor(i*log10(i)+1)==s.size()) break; //求位数
	cout<<i; 
	fclose(stdin);
	fclose(stdout);
	return 0;
}

猜你喜欢

转载自blog.csdn.net/LTH060226/article/details/86696129
yy