hdu 6182

题意:给出一个n,问有多少个k,使得k的k次方<n,(k>=1)

思路:快速幂

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 typedef long long ll;
 4 const int N=1e5+10;
 5 
 6 ll hh(ll x,ll y){
 7     ll s=1;
 8     while(y){
 9         if(y&1) s=s*x;
10         x*=x;
11         y>>=1;
12     }
13     return s;
14 }
15 ll a[20];
16 int main(){
17     ll n;
18     for(ll i=1;i<=15;i++){
19         a[i]=hh(i,i);
20     }
21     while(~scanf("%lld",&n)){
22         int t=0,y;
23        for(int i=1;i<=15;i++){
24             if(a[i]>n){
25                 t=1;y=i-1;break;
26             }
27         }
28         if(t){
29             printf("%d
",y);
30         }
31         else printf("%d
",15);
32     }
33     return 0;
34 }
原文地址:https://www.cnblogs.com/hhxj/p/7459682.html