题目
解题思路
模拟
代码
#include<cstdio>
#include<iostream>
using namespace std;
long long a,b,c,d,ans,uppe;
int main()
{
cin>>a>>b>>c>>d>>uppe;
if (a<=uppe) ans=(uppe-a)/b+1; //等差数列求项数
while (c<=uppe) //枚举等比数列
{
if ((c-a)%b!=0||c<a) ans++; //判重
c*=d;
if (d==1) break; //特判
}
cout<<ans; //输出,因为数字较大,用cout
}