【CodeForces】[614A]Link/Cut Tree
2016-04-07 07:08
316 查看
因为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
相关文章推荐
- Codeforces Round #197 (Div. 2)
- Codeforces Round #198 (Div. 1)
- Codeforces 405E Codeforces Round #238 (Div. 2)E
- Codeforces 407C Codeforces Round #239 (Div. 1)C
- CodeForces 449A - Jzzhu and Chocolate
- CodeForces 449 B. Jzzhu and Cities
- codeforces 618C. Constellation
- Codeforces Round #265 (Div. 2)
- Codeforces #310 div2 C. Case of Matryoshkas
- 状态压缩DP codeforces 244 Problem C. The Brand New Function 和 codeforces 165 E. Compatible Numbers
- codeforces 16 Problem E fish
- Codeforces Round332 部分题解
- CodeForces 603A_Alternative Thinking (DP)
- CodeForces 602B_Approximating a Constant Range_DP
- Codeforces round #247 for Div. 2
- Codeforces Round #246 (Div. 2)
- Codeforces #264(div 2)D.Gargari and Permutations
- Codeforces Round #236 (Div. 2)------A,B
- codeforces 257 div2 B
- Codeforces Gym100571A Cursed Query