POW.cpp

PHOTO EMBED

Thu Sep 19 2024 05:40:30 GMT+0000 (Coordinated Universal Time)

Saved by @LizzyTheCatto

#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;
}
content_copyCOPY

https://www.programiz.com/cpp-programming/online-compiler/