题目大意
题目分析
显然,当 的初值为 或 时,普通训练一定比加训加训好。因为当 时,怎么乘都是 。当 时,如果加训,则 变为 ,如果普通训练,则 变为 ,显然后者更优。 剩下的直接乘就完了。
注意
一定要特判 的情况,不然会死循环 TLE。
代码实现
#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;
}