Link/Cut Tree CodeForces - 614A 暴力+爆 long long 处理
题意:
给你一个区间[l,r],让你从小到大输出k^x,设y=k^x,要保证y在区间[l,r]中
题解:
就算k是最小的2也不需要枚举多少次就到long long的极限了,所以暴力没商量,根本不会TLE
然后就是爆long long处理,比如r特别大,当k^x=<r但是k^(x+1)就爆long long了,这个要注意一下
代码:
1 #include<stdio.h>
2 #include<string.h>
3 #include<iostream>
4 #include<algorithm>
5 #include<queue>
6 #include<map>
7 #include<vector>
8 #include<math.h>
9 #define mem(a,x) memset(a,x,sizeof(a))
10 using namespace std;
11 typedef long long ll;
12 const int maxn=1200000+10;
13 const int mod=26;
14 const int INF=0x3f3f3f3f;
15 const int Times = 10;
16 const int N = 5500;
17 int main()
18 {
19 ll l,r,k;
20 cin >> l >> r >> k;
21 int isp = 0;
22 ll ans = 1;
23 while(1)
24 {
25 if( ans>=l && ans<=r )
26 {
27 cout << ans << " ";
28 isp = 1;
29 }
30 if( r/ans<k ) // 即判断r<ans*k,
31 {
32 break ; // 因为ans*k可能越界,所有用除法判断
33 }
34 ans*=k;
35 }
36 if( isp==0 )
37 {
38 cout << "-1" <<endl;
39 }
40 else
41 {
42 cout << endl;
43 }
44 return 0;
45 }
Link/Cut Tree CodeForces - 614A 暴力+爆 long long 处理的更多相关文章
- [CodeForces - 614A] A - Link/Cut Tree
A - Link/Cut Tree Programmer Rostislav got seriously interested in the Link/Cut Tree data structure, ...
- Codeforces Round #339 (Div. 2) A. Link/Cut Tree 水题
A. Link/Cut Tree 题目连接: http://www.codeforces.com/contest/614/problem/A Description Programmer Rostis ...
- 614A - Link/Cut Tree 数乘
A. Link/Cut Tree time limit per test 2 seconds memory limit per test 256 megabytes input standard in ...
- Link Cut Tree学习笔记
从这里开始 动态树问题和Link Cut Tree 一些定义 access操作 换根操作 link和cut操作 时间复杂度证明 Link Cut Tree维护链上信息 Link Cut Tree维护子 ...
- Link Cut Tree 总结
Link-Cut-Tree Tags:数据结构 ##更好阅读体验:https://www.zybuluo.com/xzyxzy/note/1027479 一.概述 \(LCT\),动态树的一种,又可以 ...
- B - Link/Cut Tree
Problem description Programmer Rostislav got seriously interested in the Link/Cut Tree data structur ...
- link cut tree 入门
鉴于最近写bzoj还有51nod都出现写不动的现象,决定学习一波厉害的算法/数据结构. link cut tree:研究popoqqq那个神ppt. bzoj1036:维护access操作就可以了. ...
- Link/cut Tree
Link/cut Tree 一棵link/cut tree是一种用以表示一个森林,一个有根树集合的数据结构.它提供以下操作: 向森林中加入一棵只有一个点的树. 将一个点及其子树从其所在的树上断开. 将 ...
- 洛谷P3690 Link Cut Tree (模板)
Link Cut Tree 刚开始写了个指针版..调了一天然后放弃了.. 最后还是学了黄学长的板子!! #include <bits/stdc++.h> #define INF 0x3f3 ...
随机推荐
- 行业动态 | 利用Cassandra数据库揭开家族祖先的秘密
FamilySearch选择了基于Apache Cassandra的DataStax Enterprise (DSE)来加速用户增长,并通过更快的反应时间.高可用性以及零数据库宕机来提供强大的 ...
- Python使用Protobuf&&如何赋值&&如何正反序列化
前言 使用protobuf主要是两个步骤,序列化和反序列化. 关于Proto有哪些数据类型,然后如何编写,此处就不赘述了,百度一下有很多. 此文主要是总结,python使用protobuf的过程,如何 ...
- MySQL select 语句指定字段查询
指定字段查询 SELECT 语法 SELECT [ALL | DISTINCT] {* | table.* | [table.field1[as alias1][,table.field2[as al ...
- kubernetes机理之调度器以及控制器
一 了解调度器 1.1 调度器是如何将一个pod调度到节点上的 我们都已然知晓了,API服务器不会主动的去创建pod,只是拉起系统组件,这些组件订阅资源状态的通知,之后创建相应的资源,而负责调度po ...
- kubectl工具管理应用
kubectl工具管理应用 创建一个pod [root@k8s-master ~]# kubectl run nginx --replicas=3 --labels="app=nginx-e ...
- 三节锂电池充电管理芯片,IC电路图如何设计
关于三节锂电池供电的产品,在三节锂电池上,需要三个电路系统: 1,三节锂电池保护电路, 2,三节锂电池充电电路, 3,三节锂电池输出电路. 1.三节锂电池保护电路,芯片电路图 控制三节锂电池池的充电电 ...
- JVM(四)打破双亲委派和SPI机制
前言: 我们都知道判断两个类是不是同一个,要根据类加载器和全限定名.这是为什么呢?为什么不同的类加载器加载同一个类是不同的呢? 答案就是,不同的类加载器所加载的类在方法区的存储空间是不同的即Insta ...
- c#使用谷歌身份验证GoogleAuthenticator
此功能相当于给系统加了个令牌,只有输入对的一组数字才可以验证成功.类似于QQ令牌一样. 一丶创建最核心的一个类GoogleAuthenticator 此类包含了生成密钥,验证,将绑定密钥转为二维码. ...
- Redis持久化之父子进程与写时复制
之所以将Linux底层的写时复制技术放在Redis篇幅下,是因为Redis进行RDB持久化时,BGSAVE(后面称之为"后台保存")会开辟一个子进程,将数据从内存写进磁盘,这儿我产 ...
- tcp的3次握手4次挥手