CodeForces 614 A. Link/Cut Tree(水~)
来源:互联网 发布:小说改编的网络剧2015 编辑:程序博客网 时间:2024/05/16 11:30
Description
给出一个区间[l,r]和一整数k,升序输出区间[l,r]中所有满足k^t的数,如果不存在这样的数则输出-1
Input
三个整数l,r,k(1<=l<=r<=10^18,2<=k<=10^9)
Output
升序输出区间[l,r]中所有满足k^t的数
Sample Input
1 10 2
Sample Output
1 2 4 8
Solution
水题,注意乘法可能会爆long long,所以每次判断与r的关系时要用除法
Code
#include<cstdio>#include<iostream>#include<algorithm>#include<cmath>using namespace std;typedef long long ll;int main(){ ll l,r,k; while(~scanf("%I64d%I64d%I64d",&l,&r,&k)) { ll ans=1ll;int flag=0; while(ans<=r) { if(ans>=l) flag=1,printf("%I64d ",ans); if(ans>r/k)break; ans*=k; } if(!flag)printf("-1"); printf("\n"); } return 0;}
0 0
- CodeForces 614 A. Link/Cut Tree(水~)
- Codeforces 614 A Link/Cut Tree
- codeforces 614A Link/Cut Tree
- CodeForces 614A Link/Cut Tree
- codeforces 614A Link/Cut Tree
- codeforces 614 A. Link/Cut Tree
- 【CodeForces】[614A]Link/Cut Tree
- Codeforces-----614A---Link/Cut Tree---数学水题
- Codeforces--614A--Link/Cut Tree(数学)(暴力求解)
- CodeForces 614A. Link/Cut Tree【坑精度!!!】
- 614A Link/Cut Tree
- Link/Cut Tree CodeForces
- A. Link/Cut Tree
- Codeforce 614A Link/Cut Tree 水题
- Codeforces Round #339 (Div. 2) A. Link/Cut Tree - Codeforces(思维)
- cf#339-A. Link/Cut Tree-水
- Codeforces Round #339 (Div. 2) A. Link/Cut Tree
- Codeforces Round #339 (Div. 2) A.Link/Cut Tree
- 活动(activity)的四种启动模式
- 在javascript中取页面中的值
- Swift中的?与!区别分析
- [XenServer] 修改默认安装XenServer系统盘(4G)大小
- FM hal层的一些接口
- CodeForces 614 A. Link/Cut Tree(水~)
- java.lang.IndexOutOfBoundsException: setSpan (26 ... 26) ends beyond length 10
- 单片机寄存器
- BZOJ 3910: 火车|LCA|并查集
- 4281: [ONTAK2015]Związek Harcerstwa Bajtockiego 倍增LCA
- HBase超详细介绍
- ubuntu14.04安装与配置cloudmonkey
- Cocoa Touch事件处理流程--响应者链
- 9. UIActionSheet