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 ...
随机推荐
- Android手机号码不是所有的都能获取
手机号码不是所有的都能获取.只是有一部分可以拿到.这个是由于移动运营商没有把手机号码的数据写入到sim卡中.SIM卡只有唯一的编号,供网络与设备识别那就是IMSI号码,手机的信号也可以说是通过这个号码 ...
- JVM-class文件完全解析-访问标志
访问标志 在前面分析了 class文件的魔数,次版本号,主版本号,常量池入口,常量池,那么在常量池结束后,紧接着的两个字节代表访问标志(access_flages).这个标志用于识别一些类或者接口层次 ...
- 学会使用Ogitor
这几天在用Ogre读取Ogitor的场景,遇到了不少问题,在网上也找不到详细的说明,虽然读取Ogitor的场景对很多人来说太简单了,但对一些新手来说就有点难了,我刚开始就觉得是无从下手,因此简单的描述 ...
- 50元制作PS2键盘无线监控装置
0×00 什么是Arduino Arduino实际上就是一种开发板,将微控制器和必需的元件集成在一块电路板上,扩展出完善的接口和针脚,就可以接上各种各样的传感器,完成你心中的设计,你也可以把它 ...
- 桟的min实现:O(1)时间复杂度
实现桟的push和pop操作,以及桟的min操作返回桟中的最小值,要求这三个操作的时间复杂度均为O(1). 在Java中可以使用LinkedList实现桟的各种操作,这里使用双向链表实现桟的push和 ...
- BZOJ 3531(树链剖分+线段树)
Problem 旅行 (BZOJ 3531) 题目大意 给定一颗树,树上的每个点有两个权值(x,y). 要求维护4种操作: 操作1:更改某个点的权值x. 操作2:更改某个点的权值y. 操作3:求a-- ...
- C#使用Fixed创建固定大小的缓冲区
在 C# 中,可以使用 fixed 语句在数据结构中创建带有固定大小数组的缓冲区. 使用现有代码(如使用其他语言.预先存在的 DLL 或 COM 项目编写的代码)时,这种方法非常有用. 固定数组可采用 ...
- Push推送原理
Push 的工作机制 APNS 是Apple Push Notification Service(Apple Push服务器)的缩写,是苹果的服务器. 推送可以分为三个阶段. 第一阶段:.net应用程 ...
- 转:Web.config配置文件详解(新手必看)
转:http://www.cnblogs.com/gaoweipeng/archive/2009/05/17/1458762.html 花了点时间整理了一下ASP.NET Web.config配置文件 ...
- why we need virtual key word
http://stackoverflow.com/questions/2391679/why-do-we-need-virtual-methods-in-c 简言之,声明基类时,而实际指向派生类.如果 ...