2017-08-31 16:48:00

writer:pprp

这个题比较容易,我用的是快速幂

写了一次就过了

题目如下:

A Math Problem

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

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.

1≤n≤10^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
Sample Output
1
2

Input

There are no more than 50 test cases.

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

1≤n≤10^18

 
题目分析:
给你一个n,问你最大的 k ^ k <= n的 k的值,你可以用电脑上自带的计算器算一算,大概范围15^15就已经超过18位了,所以可以从15开始倒着枚举
 
代码如下:
#include <iostream>

using namespace std;
typedef long long ll; //a ^ a
__int64 POW(ll a)
{
__int64 result = ;
ll base = a;
ll tmp = a;
while(tmp > )
{
if((tmp & ) == )
result = result * base;
base = base * base;
tmp >>= ;
}
return result;
} //int main()
//{
// ll a;
// cin >> a;
// cout << POW(a) << endl;
//
// return 0;
//} int main()
{
ios::sync_with_stdio(false);
__int64 n;
while(cin >> n)
{
for(int i = ; i >= ; i--)
{
if(POW(i) <= n)
{
cout << i << endl;
break;
}
}
}
return ;
}

2017ACM/ICPC广西邀请赛-重现赛 1001 A Math Problem的更多相关文章

  1. 2017ACM/ICPC广西邀请赛-重现赛 1007.Duizi and Shunzi

    Problem Description Nike likes playing cards and makes a problem of it. Now give you n integers, ai( ...

  2. 2017ACM/ICPC广西邀请赛-重现赛 1010.Query on A Tree

    Problem Description Monkey A lives on a tree, he always plays on this tree. One day, monkey A learne ...

  3. 2017ACM/ICPC广西邀请赛-重现赛 1004.Covering

    Problem Description Bob's school has a big playground, boys and girls always play games here after s ...

  4. 2017ACM/ICPC广西邀请赛-重现赛

    HDU 6188 Duizi and Shunzi 链接:http://acm.hdu.edu.cn/showproblem.php?pid=6188 思路: 签到题,以前写的. 实现代码: #inc ...

  5. 2017ACM/ICPC广西邀请赛-重现赛1005 CS course

    2017-08-31 16:19:30 writer:pprp 这道题快要卡死我了,队友已经告诉我思路了,但是做题速度很缓慢,很费力,想必是因为之前 的训练都是面向题解编程的缘故吧,以后不能这样了,另 ...

  6. 2017ACM/ICPC广西邀请赛-重现赛(感谢广西大学)

    上一场CF打到心态爆炸,这几天也没啥想干的 A Math Problem Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/3 ...

  7. HDU 6191 2017ACM/ICPC广西邀请赛 J Query on A Tree 可持久化01字典树+dfs序

    题意 给一颗\(n\)个节点的带点权的树,以\(1\)为根节点,\(q\)次询问,每次询问给出2个数\(u\),\(x\),求\(u\)的子树中的点上的值与\(x\)异或的值最大为多少 分析 先dfs ...

  8. 2017ACM/ICPC广西邀请赛

    A.A Math Problem #include <bits/stdc++.h> using namespace std; typedef long long ll; inline ll ...

  9. 2017ACM/ICPC广西邀请赛 Duizi and Shunzi

    题意:就是一个集合分开,有两种区分 对子:两个相同数字,顺子:连续三个不同数字,问最多分多少个 解法:贪心,如果当前数字不构成顺子就取对子 /2,如果可以取顺子,那么先取顺子再取对子 #include ...

随机推荐

  1. ssh登录服务器

    ssh -i /home/zhangsuosheng/mykey.pub myusername@111.111.111.111

  2. 安卓android的联系人的contacts, raw contacts, and data的区别

    https://stackoverflow.com/questions/5151885/android-new-data-record-is-added-to-the-wrong-contact/51 ...

  3. python与c语言交互应用实例

    1.python向c语言写数据 1) 先将接收端编译成一个共享链接库gcc/arm-linux-gnueabihf-gcc -o bluetooth_proxy.so -shared -fPIC bl ...

  4. Spring boot 打包瘦身方法

    背景 随着spring boot 的流行.越来越多的来发着选择使用spring boot 来发 web 应用. 不同于传统的 web 应用 需要 war 包来发布应用. spring boot 应用可 ...

  5. centos7提示ifconfig command not found解决

    安装centos7时,选择了minimal install的话,没有安装网络组件. yum install net-tools 可以解决问题.

  6. SQL Server outer apply 和 cross apply

    先说点题外话,因为后面我会用到这个函数. 前两天自定义了一个 sql 的字符串分割函数(Split),不过后来发现有点问题,例如: select * from Split(default,'123,4 ...

  7. XDU 1011

    解法1:TLE #include<stdio.h> int main() { long long n; //freopen("in.txt","r" ...

  8. hadoop开发setjar方法

    屏蔽 //job.setJar("/Users/sumeng/IdeaProjects/cloudHadoop/out/artifacts/cloudHadoop_jar/cloudHado ...

  9. List泛型集合转DataTable

    自存,此方法可以防止出现DataSet不支持System.Nullable的错误 public static DataTable ToDataTable<T>(IEnumerable< ...

  10. C++ vector 用法

    转自http://www.cnblogs.com/wang7/archive/2012/04/27/2474138.html#undefined 在c++中,vector是一个十分有用的容器,下面对这 ...