输入等比数列的取值范围和公比,其中前2个数字是等比数列的最小值lbound和最大值ubound,第3个数值是公比ratio。
输入的数据很小,不会产生溢出。
输出
输出[lbound,ubound]区间内,以ratio为公比的等比数列。注意:ubound给出的是数列的上界,并不一定是数列中的值,如样例所示。
样例输入
1 10 3
样例输出
1 3 9
#include <stdio.h>
#include <math.h>
int main()
{
int l,u,r;
int n = 1;
scanf("%d%d%d",&l,&u,&r);
while(u-(int)l*pow(r,n-1)>=0)
{
printf("%d\n",l*(int)pow(r,n-1));
n++;
}
return 0;
}