题解:P14027 【MX-X20-T1】「FAOI-R7」加训加训
Clouds_dream · · 题解
题目大意
题目传送门
题目分析
显然,当
剩下的直接乘就完了。
::::warning[注意]
一定要特判
代码实现
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define int long long
#define fst ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int a,b,k;// 如题意所述
int ans=0;
signed main()
{
fst
cin>>a>>b>>k;
if(k==1){// 一定要特判
cout<<b-a;
return 0;
}
while(a<b){
if(a==0||a==1){
ans++;
a+=k;
continue;
}
ans++;
a*=k;
}
cout<<ans;
return 0;
}