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

2017ICPC/广西邀请赛1001(水)HDU6181

时间:2017-09-04 22:39:57      阅读:302      评论:0      收藏:0      [点我收藏+]

标签:number   ota   sample   icp   contain   type   amp   test   ssi   

A Math Problem

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


Problem Description
You are given a positive integer n, please count how many positive integers k satisfy k技术分享k技术分享n技术分享 .
 

 

Input
There are no more than 50 test cases.

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

1n10技术分享18技术分享技术分享
 

 

Output
For each test case, output an integer indicates the number of positive integers k satisfy k技术分享k技术分享n技术分享 in a line.
 

 

Sample Input
1 4
 

 

Sample Output
1 2

题意 

解析  数据会爆longlong 自己快速幂找到爆点 16爆了

 1 #include <stdio.h>
 2 #include <math.h>
 3 #include <string.h>
 4 #include <stdlib.h>
 5 #include <iostream>
 6 #include <sstream>
 7 #include <algorithm>
 8 #include <string>
 9 #include <queue>
10 #include <vector>
11 using namespace std;
12 const int maxn= 200010;
13 const int inf = 0x3f3f3f3f;
14 typedef long long ll;
15 ll n;
16 ll pow1(ll a,ll b)
17 {
18   ll r=1,base=a;
19   while(b)
20   {
21     if(b&1) r*=base;
22     base*=base;
23     b>>=1;
24   }
25   return r;
26 }
27 int main(int argc, char const *argv[])
28 {
29     while(scanf("%lld",&n)==1)
30     {
31         for(int i=15;i>=0;i--)
32         {
33             if(pow1(i,i)<=n)
34             {
35                 cout<<i<<endl;
36                 break;
37             }
38 
39         }
40     }
41     return 0;
42 }

 

2017ICPC/广西邀请赛1001(水)HDU6181

标签:number   ota   sample   icp   contain   type   amp   test   ssi   

原文地址:http://www.cnblogs.com/stranger-/p/7475775.html

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