[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 ...
随机推荐
- ie 支持字体大小继承
今天需要实现字体大小继承这个效果.是这样的,在公用类里 .box 中的 .box1 的字体进行了修改.但是我的页面里不需要修改.我需要让他和 .box 一样.所以想到使用继承.但是想到继承这个属性兼容 ...
- CentOS7使用firewalld和selinux
转载自莫小安的博客:https://www.cnblogs.com/moxiaoan/p/5683743.html 如何查看和使用selinux https://blog.csdn.net/edide ...
- Lintcode521-Remove Duplicate Numbers in Array-Easy
Description Given an array of integers, remove the duplicate numbers in it. You should: Do it in pla ...
- 中文字符串和UTF-8编码字符串相互转换
中文字符串和UTF-8编码字符串相互转换 //UTF字符转换 var UTFTranslate = { Change: function(pValue) { ) { ).replace(/(%u)(\ ...
- 使用fiddler轻轻松松制造客户端接口time out的情况
1.打开fiddler,过滤出你想要的请求 2.复制出你想要中断的请求 3.设置中断这个请求,bpu+请求,回车(详情请百度fiddle默认命令) 4.ctrl+x(清楚所有的请求),刷新页面,重新获 ...
- SQL 中常用的功能函数,自定义的功能行数
在SQL Server指定的数据库中,有Programmability目录,在这个目录下,有存储过程,有功能函数. set ANSI_NULLS ON set QUOTED_IDENTIFIER ON ...
- jsp导入数据库数据写法(模板)
1.导入表格模板 <%@ page language="java" contentType="text/html; charset=utf-8" page ...
- [转][JSBSim]JSBSim的使用--飞行控制组件及其配置
http://www.jianshu.com/p/b5e9f1f5df95 飞行控制率.稳定增强系统.自动驾驶仪和其他飞控系统(航电.电气等)都能够在 JSBSim 中以独立的控制组件进行建模.JSB ...
- SQL中 根据行号设置每行数据的排序数值
根据行号自动把当前行号插入到某列中 实现排序 update tempTable set DisplayOrder = right( CAST(rownum as NVARCHAR),5) from( ...
- 力扣(LeetCode) 217. 存在重复元素
给定一个整数数组,判断是否存在重复元素. 如果任何值在数组中出现至少两次,函数返回 true.如果数组中每个元素都不相同,则返回 false. 示例 1: 输入: [1,2,3,1] 输出: true ...