614A Link/Cut Tree
来源:互联网 发布:keynote2015年版 mac 编辑:程序博客网 时间:2024/05/08 15:33
//614A Link/Cut Tree//k的n次幂,范围在[l,r],次幂爆ll的时候查水表一下#include<bits/stdc++.h>using namespace std;typedef long long ll;const ll maxn = 10e18;int main(){ ll l, r, k, ans, pre;//ans:累计乘积,pre:水表上一个ans int flag;//输出标志 cin>>l>>r>>k; ans = 1; if(l==1) cout<<1<<" "<<endl;//左限1直接输出 pre = 0; flag = 1; for(int i=1; ; i++) { ans *= k; //ans乘的时候会溢出错误,如何判断溢出,下面条件查水表,本次乘积除以上一次水表数应该是固定的基数,如果不是则溢出了 if(ans>maxn || ans<0 || pre!=0 && ans/pre!=k) break;//这里的pre!=0并不是除零判断,而是表示pre更新过了(当然也可以说从第二个数开始) pre = ans; if(l<=ans && ans<=r) { cout<<ans<<" "<<endl; flag = 0; } else if(ans<l) continue; else if(ans>r) break; } if(flag && l!=1) cout<<"-1"<<endl;//没有任何输出则输出-1 return 0;}
0 0
- 614A Link/Cut Tree
- A. Link/Cut Tree
- Codeforces 614 A Link/Cut Tree
- codeforces 614A Link/Cut Tree
- Codeforce 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---数学水题
- cf#339-A. Link/Cut Tree-水
- Codeforences #339 A. Link/Cut Tree
- 【SPOJ-QTREE】Query on a tree【Link-Cut Tree】
- 【link-cut tree】
- Link Cut Tree (paint)
- 如何为Joomla主流模板添加统计代码
- 610C Harmony Analysis
- 玻璃钢机翼
- UVA10954 Add All (优先队列)
- E49 升级CPU i7-3720qm
- 614A Link/Cut Tree
- 614B Gena's Code
- Java面向对象编程-第14章数组
- struts2 纯注解 却提示There is no Action mapped for namespace
- Java Nio 八、Java NIO FileChannel
- 615A Running Track
- HDU 4856Tunnels(状压DP)
- 615B Longtail Hedgehog
- oracle----------用户管理