码迷,mamicode.com
首页 > 其他好文 > 详细

hdu 6182

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

标签:print   ace   lld   span   log   color   include   多少   col   

题意:给出一个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

标签:print   ace   lld   span   log   color   include   多少   col   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!