#include <bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(NULL);
int l;
int r;
int x;
cin >> l >> r >> x;
int ans = 1;
int count = 0;
while(ans <= r){
if(ans >= r && ans <= r){
cout << ans << " ";
count = count + 1;
}
ans *= x;
}
if(count == 0){
cout << "-1";
}
return 0;
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter