A Math Problem

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 4965    Accepted Submission(s): 1543


 

Problem Description

You are given a positive integer n, please count how many positive integers k satisfy kk≤n.

 

Input

There are no more than 50 test cases.

Each case only contains a positivse integer n in a line.

1≤n≤10^18

 

Output

For each test case, output an integer indicates the number of positive integers k satisfy kk≤n in a line.

 

Sample Inpu

1 4

 

Sample Output

1 2

 

大海啊全是水,骏马啊四条腿~

 

根据数据范围,只需要求出前15个k^k即可。

代码:

#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
using namespace std;
#define ll long long
#define inf 0x3f3f3f3f
#define mem(a,b) memset(a,b,sizeof(a))
#define closeio std::ios::sync_with_stdio(false)

ll a[20];

int main()
{
	int i,j;
	ll n;
	for(i=1;i<=15;i++)
	{
		a[i]=1;
		for(j=1;j<=i;j++)
			a[i]*=i;
	}
	while(cin>>n)
	{
		int s=0;
		for(i=1;i<=15;i++)
		{
			if(a[i]<=n)
				s++;
			else
				break;
		}
		cout<<s<<endl;
	}
	return 0;
}