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. ROS 笔记

    ros的编程范式 - ros认为,linux平台下,机器人的软件由一个个小程序组成,这些小程序称为node,每个小程序负责一部分功能 - ros实现的框架就是,小程序的并发执行+相互通信,程序(进程) ...

  2. IIs7下配置php

    因为一个朋友的服务器是window的需要两个版本的php,一个是现在用的php5.2,现在要用一个5.3的版本,所以考虑IIS下的配置. 1.首先当然是要下载一份php了,我采用的是免安装的,很方便, ...

  3. Flask用Flask-SQLAlchemy连接MySQL

    安装 pip3 install Flask-SQLAlchemy 测试环境目录结构 settings.py DIALECT = 'mysql' DRIVER = 'pymysql' USERNAME ...

  4. Mysql大数据量分页优化

    假设有一个千万量级的表,取1到10条数据: select * from table limit 0,10; select * from table limit 1000,10; 这两条语句查询时间应该 ...

  5. 【云安全与同态加密_调研分析(5)】云安全标准现状与统计——By Me

  6. openfire 使用已有的数据库作为用户认证数据库 Custom Database Integration Guide

    http://download.igniterealtime.org/openfire/docs/latest/documentation/db-integration-guide.html Intr ...

  7. oracle 查看隐藏参数

    隐藏参数 (hidden parameters) ,由oracle内部使用,以 '_' 开头. 可以通过以下两种方式查看所有隐藏参数: SELECT   i.ksppinm name, i.ksppd ...

  8. H5移动端的一些坑、、、

    H5项目常见问题及注意事项 Meta基础知识: H5页面窗口自动调整到设备宽度,并禁止用户缩放页面 //一.HTML页面结构 <meta name="viewport" co ...

  9. flask内置session原理

    内置session原理 请求到来 当请求进来之后,先执行Flask对象的 __call__ 方法 def wsgi_app(self, environ, start_response): # 获取请求 ...

  10. jQuery HTML操作学习笔记

    学习资料 jQuery教程 获取 1.获取.设置元素的内容 1.1获取或设置目标元素的文本内容 语法 $(selector).text(); 获取元素文本内容 $(selector).text(con ...