首页 > 其他 > 详细

hdu 6182

时间:2017-08-31 18:58:18      阅读:300      评论:0      收藏:0      [点我收藏+]

题意:给出一个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\n",y);
30         }
31         else printf("%d\n",15);
32     }
33     return 0;
34 }

 

hdu 6182

原文:http://www.cnblogs.com/hhxj/p/7459682.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!