[CodeForces - 614A] A - Link/Cut Tree
A - Link/Cut Tree
Programmer Rostislav got seriously interested in the Link/Cut Tree data structure, which is based on Splay trees. Specifically, he is now studying the exposeprocedure.
Unfortunately, Rostislav is unable to understand the definition of this procedure, so he decided to ask programmer Serezha to help him. Serezha agreed to help if Rostislav solves a simple task (and if he doesn't, then why would he need Splay trees anyway?)
Given integers l, r and k, you need to print all powers of number k within range from l to r inclusive. However, Rostislav doesn't want to spent time doing this, as he got interested in playing a network game called Agar with Gleb. Help him!
Input
The first line of the input contains three space-separated integers l, r and k (1 ≤ l ≤ r ≤ 1018, 2 ≤ k ≤ 109).
Output
Print all powers of number k, that lie within range from l to r in the increasing order. If there are no such numbers, print "-1" (without the quotes).
Example
1 10 2
1 2 4 8
2 4 5
-1
Note
Note to the first sample: numbers 20 = 1, 21 = 2, 22 = 4, 23 = 8 lie within the specified range. The number 24 = 16 is greater then 10, thus it shouldn't be printed.
题目意思是,给你一个区间和一个数,求有几个这个数的正整数次幂在这个区间内.
由于数据很大,在判断是否超出R的时候可能会爆long long.所以在判断时不能用乘,而应该用除,这样就不会爆了.
#include<cstdio> #include<algorithm> using namespace std; long long L,R,K; int main(){ scanf("%lld%lld%lld",&L,&R,&K); ; ; ;} ; R/x>=K; i++){ x*=K; ;} } ) puts("-1"); ; }
[CodeForces - 614A] A - Link/Cut Tree的更多相关文章
- 【CodeForces 614A】Link/Cut Tree
题 题意 给你一个区间,求里面有多少个数是k的次方. 分析 暴力,但是要注意这题范围会爆long long,当k=1e8: l=1:r=1e18时 k²=1e16,判断了是≤r,然后输出,再乘k就是1 ...
- 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 入门
鉴于最近写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 ...
- LCT总结——概念篇+洛谷P3690[模板]Link Cut Tree(动态树)(LCT,Splay)
为了优化体验(其实是强迫症),蒟蒻把总结拆成了两篇,方便不同学习阶段的Dalao们切换. LCT总结--应用篇戳这里 概念.性质简述 首先介绍一下链剖分的概念(感谢laofu的讲课) 链剖分,是指一类 ...
- bzoj2049 [Sdoi2008]Cave 洞穴勘测 link cut tree入门
link cut tree入门题 首先说明本人只会写自底向上的数组版(都说了不写指针.不写自顶向下QAQ……) 突然发现link cut tree不难写... 说一下各个函数作用: bool isro ...
- P3690 【模板】Link Cut Tree (动态树)
P3690 [模板]Link Cut Tree (动态树) 认父不认子的lct 注意:不 要 把 $fa[x]$和$nrt(x)$ 混 在 一 起 ! #include<cstdio> v ...
随机推荐
- 3、Ansible playbooks(Hosts、Users、tasks、handlers、变量、条件测试(when、迭代)、templates)
Ansible playbooks playbook是由一个或多个“play”组成的列表.play的主要功能在于将事先归并为一组的主机装扮成事先通过ansible中的task定义好的角色.从根本上来讲 ...
- javascript知识体系
JAVASCRIPT 篇 0.基础语法 javascript基础语法包括:变量定义.数据类型.循环.选择.内置对象等. 数据类型有string,number,boolean,null,undefine ...
- Go 字典(Map)
比较熟悉 Python 的对于字典肯定不会陌生,在 Go 中 map 就是 Python 中字典的概念,它的基本格式是 map[keyType]valueType .map 的读取和设置和 slice ...
- _itemmod_extract_enchant随机附魔提取
技能 脚本 spell_extract_enchant 提取一条随机FM 随机FM提取 物品脚本:1.spell_extract_enchant 提取一条随机FM2.spell_extract_enc ...
- Springboot+JdbcTemplate +thymeleaf 页面 做迷你版的bug系统
https://www.cnblogs.com/qianjinyan/p/10065160.html 在我上一篇随笔中介绍了关于要做的系统的数据结构,连接如上 今天实现连接mssql server, ...
- 学大数据是先学java还是先学python?
大数据的发展趋势日渐明显,但是进入这个领域的门槛不小,除了要有心理准备,其次就是要付诸实际行动中去学习. 学习方法有很多,在没有基础的前提下,自学是因人而异是有难度.其次是大数据目前的工作方向主要是三 ...
- d3 data()数据绑定中的key函数
官网https://github.com/d3/d3-selection/blob/master/README.md#selection_data var data = [ {name: " ...
- C#通过 “枚举数支持在指定类型的集合上进行简单迭代” 的概念获取List的一种方式
using System; using System.Collections.Generic; using System.Linq; namespace myMethod { class Animal ...
- 第 3 章 镜像 - 016 - Dockerfile 常用指令
Dockerfile 常用指令 1.FROM 指定base镜像2.MAINTAINER 设置镜像的作者,可以为任意字符串3.COPY 从build context 复制到镜像 COPY 支持两种形式: ...
- ado.net常用操作
目录 一.ADO.NET概要 二.ADO.NET的组成 三.Connection连接对象 3.1.连接字符串 3.1.1.SQL Server连接字符串 3.1.2.Access连接字符串 3.1.3 ...