博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Codeforces Round #339 (Div. 2) A. Link/Cut Tree 水题
阅读量:6657 次
发布时间:2019-06-25

本文共 1383 字,大约阅读时间需要 4 分钟。

A. Link/Cut Tree

题目连接:

Description

Programmer Rostislav got seriously interested in the Link/Cut Tree data structure, which is based on Splay trees. Specifically, he is now studying the expose procedure.

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).

Sample Input

1 10 2

Sample Output

1 2 4 8

Hint

题意

给你l,r,k

让你输出k在[l,r]里面的幂

题解:

很水的题,但是会爆long long

所以在乘的时候注意一下,或者用python就好了

代码

#include
using namespace std;vector
T;int main(){ long long l,r,k; cin>>l>>r>>k; int flag = 0; long long tmp = 1; while(tmp<=r) { if(tmp>=l) { T.push_back(tmp); flag = 1; } if(r*1.0/tmp*1.0

转载地址:http://hiqto.baihongyu.com/

你可能感兴趣的文章
Java数组冒泡排序与二维数组
查看>>
字体下载大宝库:30款好看的免费英文字体
查看>>
R730 安装server 2008
查看>>
X8 Root方法
查看>>
JAVA并发处理经验(四)并行模式与算法5:并行排序模式-奇偶性排序
查看>>
html常见兼容性问题?
查看>>
Jquery封装tab选项卡
查看>>
gitlab修改项目的url
查看>>
完全用链表实现的贪吃蛇
查看>>
平板不会取代办公PC 但某种技术可能会
查看>>
理解javascript面向对象的基本模式
查看>>
体验无人值守安装RHEL6
查看>>
Unable to access ossec directory的解决
查看>>
super daemon与tcp_wrappers结合应用小结(实验部分)
查看>>
nginx + uwsgi + Django 应用部署
查看>>
乾颐堂军哥HCIE12-BGP的对等体组和BGP的路由操控理论和实验
查看>>
windows中取消活动分区状态
查看>>
NTP 时间同步服务器配置实例(CISCO 7200路由)
查看>>
文件查找工具find
查看>>
mooon-agent设计要点
查看>>