P28609 [洛谷] 【Mathematics 1】Xiao Hao's Power Operation
普及+
题目描述

Problem Description

Power operations have been bothering Xiao Hao lately, and he has encountered some problems.
He needs to find all $w^i$ such that $l \le w^i \le r$, and he has turned to you for help.

Input Format

The input consists of a single line containing three integers: $l, r, w$.

Output Format

The output should be a single line containing all numbers that meet the condition, separated by spaces.
If there are no numbers that meet the condition, output $-1$.

Sample Input and Output

Sample Input #1

1 10 2

Sample Output #1

1 2 4 8

Sample Input #2

2 4 5

Sample Output #2

-1

Notes

【Data Range】
For $100\%$ of the data: $1 \le l \le r \le 1 \times 10^{18}$, $1 \le w \le 10^9$.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
1 10 2
样例输出
1 2 4 8