codeforces-614【A精度】
来源:互联网 发布:filco mac 键位 编辑:程序博客网 时间:2024/06/05 11:53
题目链接:点击打开链接
大意:给出一个区间,让你打印出 k 的n次方存在此区间内的数。
#include<cstdio>#include<cmath>#define LL long longusing namespace std;LL l,r,k;/* LL qpow(LL x,LL y){LL ans=1;while(y){if(y&1)ans*=x;x*=x;y>>=1;}return ans;}int main(){while(~scanf("%lld%lld%lld",&l,&r,&k)){LL a=1LL*log(l*1.0)/log(k*1.0)+1e-10; // 加精度逼近 LL b=1LL*log(r*1.0)/log(k*1.0)+1e-10; while(qpow(k,a)<l) { a++; } while(qpow(k,b)>r) { b--; } if(a>b) { puts("-1"); continue; } LL ans=qpow(k,a); printf("%lld ",ans);for(LL i=a+1;i<=b;i++){ans*=k;printf("%lld ",ans);}puts("");}return 0; }*/int main(){while(~scanf("%lld%lld%lld",&l,&r,&k)){bool flag=1;for(LL ans=1;;ans*=k){if(ans>=l&&ans<=r){if(!flag)printf(" ");printf("%lld",ans);flag=0;}if(ans>r/k) // 这里要提前判断,防止下一个 ans 爆 LL 而造成判断失误 break;}if(flag)puts("-1");elseputs("");}return 0;}
0 0
- codeforces-614【A精度】
- codeforces-140【A几何】【精度】
- CodeForces 614A. Link/Cut Tree【坑精度!!!】
- CodeForces 1A Theatre Square 【数学】【精度】
- 【Codeforces 140 A. New Year Table】 + 精度
- Codeforces Round #100 A. New Year Table (几何精度)
- Codeforces 140A:New Year Table(数学几何&&精度)
- Codeforces Round #320 (Div. 2) [Bayan Thanks-Round] C. A Problem about Polyline 精度控制
- CodeForces - 140A New Year Table (数学几何&精度)大圆内能放几个小圆
- CodeForces-a
- codeforces 24E (二分答案,精度控制)
- Codeforces 801C Voltage Keepsake 二分+精度
- Codeforces 903A A
- 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
- Servlet上下文
- FK外键约束
- ${pageContext.request.contextPath} 在Jsp页面报错
- 《ACM程序设计》书中题目Y(几个几@v@~~)
- Android multitype Recyclerview 设置间距 itemdecoration
- codeforces-614【A精度】
- Vim代码块注释操作方法
- 高性能JS 非阻塞方式下载 JavaScript 用 XHR 对象下载代码,并注入到页面中
- Github上传文件大小限制-Yowl,that's a big file. Try again with a file smaller than 25MB.
- URL 讲解 和 InetAddress
- iOS架构设计与分层
- Laravel简单使用
- 高性能 JS Recommended Nonblocking Pattern 推荐的非阻塞模式
- okhttp 拦截器调用。