【CodeForces】[614A]Link/Cut Tree
来源:互联网 发布:js 数组变量 编辑:程序博客网 时间:2024/05/16 12:47
因为pow会有精度丢失
所以使用了一直自乘
对于最大值
因为res有可能超出__int64
所以终止条件只需要在res自乘前写
res>r/k
效果等同于在循环开始时写
res>r (因为此时已经执行res=res*k)
#include<stdio.h>int main() {// freopen("input.txt","r",stdin);// freopen("ACoutput.txt","w",stdout); __int64 l,r,k; while(scanf("%I64d %I64d %I64d",&l,&r,&k)!=EOF) { bool flag=false; __int64 res=1; while(1) { if(res>=l&&res<=r) { printf("%I64d ",res); flag=true; } if(res>r/k) break; res*=k; } if(!flag) printf("-1"); printf("\n"); } return 0;}
题目地址:【CodeForces】[614A]Link/Cut Tree
0 0
- 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 614 A. 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 Round #339 (Div. 2) A.Link/Cut Tree
- Codeforces Round #339 (Div. 2) A. Link/Cut Tree
- Codeforces Round #339 (Div. 2) A. Link/Cut Tree - Codeforces(思维)
- 检查OGG占用端口的命令
- C/C++不同文件夹下包含头文件的方法及#include的使用
- CSP考试 2015年03月第5题 C语言实现
- 在程序中表示负无穷大的数
- cocos2d-Lua01Lua基础语法
- 【CodeForces】[614A]Link/Cut Tree
- OGG孤儿server进程的检查与处理
- Java 实例升级篇
- Red Hat Enterprise Linux Server 7.1 x86_64 下载
- cocos2d-Lua02Lua面向对象
- U盘作为启动盘的重装系统教程
- 百思不得姐自定义TabBar
- 【杭电】[2083]简易版之最短距离
- JavaScript基础教程03var动态数据类型