A Math Problem
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2572 Accepted Submission(s): 890
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≤1018
Each case only contains a positivse integer n in a line.
1≤n≤1018
Output
For each test case, output an integer indicates the number of positive integers k satisfy
kk≤n in a line.
Sample Input
14
Sample Output
12
题目解析:
这个题目的意思就是让我们求有多少个数k满足k的k次幂小于给定的数字n,题目非常简单,直接暴力就可以,只是要注意一下最大就到15即可,很简单,1A
代码:
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
ull solve(ull x)
{
ull ans=x;
for(int i=1; i<x; i++)
{
ans*=x;
}
return ans;
}
int main()
{
// freopen("in.txt","r",stdin);
int cnt;
ull n;
while(cin>>n)
{
cnt = 0;
int i=1;
while(1)
{
if(solve(i)>n||i>15)
break;
cnt++;
i++;
}
cout<<cnt<<endl;
}
return 0;
}