https://ac.nowcoder.com/acm/contest/43844/C
__int128 就是占用128字节的整数存储类型。由于是二进制,范围就是 −2127 ~ 2127−1,如果使用了 unsigned __int128,则范围变成 0 ~ 2128,即约39位数!
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
int t,l,r,k;
cin>>t;
while(t--){
__int128 temp=1;
cin>>l>>r>>k;
vector<int> v;
if(k==0){
if(l<=0&&r>=0) v.push_back(0);
if(l<=1&&r>=1) v.push_back(1);
}
else if(k==1){
if(l<=1&&r>=1) v.push_back(1);
}
else {
while(temp<=r){
if(temp>=l&&temp<=r) v.push_back(temp);
temp*=k;
}
}
if(v.size()==0) cout<<"None."<<'\n';
else {
for(auto it:v) cout<<it<<' ';
cout<<'\n';
}
}
return 0;
}