Codeforces Round #339 Div.2 A - Link/Cut Tree
第一次正式参加常规赛想想有些小激动的呢
然后第一题就被hack了 心痛 _(:зゝ∠)_
tle点在于越界 因此结束循环条件从乘变为除 done
//等等 这题没过总评 让我静静........
//改天再来改吧.......
#include <cstdio> int main()
{
long long l, r, k;
scanf("%I64d%I64d%I64d", &l, &r, &k);
if(k > r) puts("-1");
else{
long long i = ;
for(; r / i >= k; i *= k){
if(i >= l) printf("%I64d ", i);
}
printf("%I64d\n", i);
}
return ;
}
----------------------------------------------Updata----------------------------------------------------
k > r 时 如果l == 1 则要输出一个1
另外 如果过程中直接跳过这个循环 是要输出一个-1的
#include <cstdio>
int main()
{
long long l, r, k;
scanf("%I64d%I64d%I64d", &l, &r, &k);
if(k > r){
if(l > ) puts("-1");
else puts("");
}
else{
long long i = ;
for(; r / i >= k; i *= k){
if(i >= l) printf("%I64d ", i);
}
if(i >= l) printf("%I64d\n", i);
else puts("-1");
}
return ;
}
Codeforces Round #339 Div.2 A - Link/Cut Tree的更多相关文章
- Codeforces Round #339 (Div. 2) A. Link/Cut Tree 水题
A. Link/Cut Tree 题目连接: http://www.codeforces.com/contest/614/problem/A Description Programmer Rostis ...
- Codeforces Round #670 (Div. 2) C. Link Cut Centroids (dfs,树)
C. Link Cut Centroids Fishing Prince loves trees, and he especially loves trees with only one centro ...
- Codeforces Round #339 (Div.2)
A. Link/Cut Tree time limit per test 2 seconds memory limit per test 256 megabytes input standard in ...
- Codeforces Round #339 (Div. 2) A
Description Programmer Rostislav got seriously interested in the Link/Cut Tree data structure, which ...
- Codeforces Round #319 (Div. 1) B. Invariance of Tree 构造
B. Invariance of Tree Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/576/ ...
- Codeforces Round #339 (Div. 1) C. Necklace 构造题
C. Necklace 题目连接: http://www.codeforces.com/contest/613/problem/C Description Ivan wants to make a n ...
- Codeforces Round #339 (Div. 1) A. Peter and Snow Blower 计算几何
A. Peter and Snow Blower 题目连接: http://www.codeforces.com/contest/613/problem/A Description Peter got ...
- Codeforces Round #339 (Div. 2) B. Gena's Code 水题
B. Gena's Code 题目连接: http://www.codeforces.com/contest/614/problem/B Description It's the year 4527 ...
- Codeforces Round #339 (Div. 1) B. Skills 暴力 二分
B. Skills 题目连接: http://www.codeforces.com/contest/613/problem/B Description Lesha plays the recently ...
随机推荐
- MySQL的高级查询
高级查询 1.连接查询(对列的扩展) 第一种形式select * from Info,Nation #会形成笛卡尔积 select * from Info,Nation where Info.Nati ...
- 【IOS基础知识】NSTimer定时器使用
1.声明 NSTimer *timer; 2.定义 timer = [NSTimerscheduledTimerWithTimeInterval:1.0ftarget:selfsele ...
- javascript笔记3-面向对象的程序设计-创建对象
javascript的对象:无序属性的集合,而每个属性可以包含基本值.对象或者函数.举例: var person = new Object(); person.name = "Nichola ...
- 极客DIY:RFID飞贼打造一款远距离渗透利器
本文使用最新的渗透工具RFID飞贼(Tastic RFID Thief)和RFID感应破解技术来获取一些拥有安防的建筑物的访问权限. Tastic RFID Thief是一个无声远距离RFID读卡器, ...
- 极客DIY:廉价电视棒玩转GNSS-SDR,实现GPS实时定位
0×00 前言 GNSS是Global Navigation Satellite System的缩写.中文称作:全球卫星导航系统.全球导航卫星系统. GNSS泛指所有的卫星导航系统,包括全球的.区域的 ...
- 爬虫学习----获取cookie
http://blog.csdn.net/samxx8/article/details/21535901 1.获取cookie import urllib import http.cookiejarc ...
- 数据结构 《5》----二叉搜索树 ( Binary Search Tree )
二叉树的一个重要应用就是查找. 二叉搜索树 满足如下的性质: 左子树的关键字 < 节点的关键字 < 右子树的关键字 1. Find(x) 有了上述的性质后,我们就可以像二分查找那样查找给定 ...
- C# 线程问题
一:概述和概念 C#支持通过多线程并行地执行代码,一个线程有它独立的执行路径,能够与其它的线程同时地运行.一个C#程序开始于一个单线程,这个单线程是被CLR和操作系统(也称为"主线程&quo ...
- ZJOI 仓库建设 (斜率DP)
f[i]=min(f[j]+w[j,i])+c[i]; j∈[0,i-1] w[j,i]=p[j+1]*(x[i]-x[j+1])+...+p[i]*(x[i]-x[i]); 最裸的DP是n^2的, ...
- HDU 5086
http://acm.hdu.edu.cn/showproblem.php?pid=5086 求所有连续区间的数字和 本质是一个乘法原理,当前位置的数字出现次数=这个数之前的数字个数*这个数之后的数字 ...