HDU 6182 A Math

A Math Problem

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

Problem Description
You are given a positive integer n, please count how many positive integers k satisfy kkn.
 
Input
There are no more than 50 test cases.

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

1n1018
 
Output
For each test case, output an integer indicates the number of positive integers k satisfy kkn in a line.
 
Sample Input
1
4
 Sample Output
1
2
 水题,打表。
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <cassert>
#include <ctime>
#include <map>
#include <set>
using namespace std;
#define lowbit(x) (x&(-x))
#define max(x,y) (x>=y?x:y)
#define min(x,y) (x<=y?x:y)
#define MAX 100000000000000000
#define MOD 1000000007
#define pi acos(-1.0)
#define ei exp(1)
#define PI 3.141592653589793238462
#define ios() ios::sync_with_stdio(false)
#define INF 1044266558
#define mem(a) (memset(a,0,sizeof(a)))
typedef long long ll;
const ll M=437893890380859375;
ll n;
ll quick_pow(ll x,ll y)
{
    ll ans=1;
    while(y)
    {
        if(y&1) ans*=x;
        x*=x;
        y>>=1;
    }
    return ans;
}
int main()
{
    while(scanf("%lld",&n)!=EOF)
    {
        if(n>=M) printf("15
");
        else
        {
            for(int i=1;i<=14;i++)
            {
                if(quick_pow(i,i)<=n && n<quick_pow(i+1,i+1))
                {
                    printf("%d
",i);
                    break;
                }
            }
        }
    }
    return 0;
}
原文地址:https://www.cnblogs.com/shinianhuanniyijuhaojiubujian/p/7463747.html