c++题解
解题思路
这道题其实就是一个数学问题,其公式为 ,也就是一个 while 判断 然后 增加。
while(n<m){
n*=(k+1);
}最后再统计一下:
while(n<m){
n*=(k+1);
t++;
}本以为用一下代码就能 AC 但——。
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b,c,t=0;
cin>>a>>b>>c;
while(a<c){
a+=a*b;
t++;
}
cout<<t;
} 90!!!。 不开 见祖宗!如果 一次操作后 n 就已经超过 范围了
代码
#include<bits/stdc++.h>
using namespace std;
int main(){
long long a,b,c,t=0;
cin>>a>>b>>c;
while(a<c){
a+=a*b;
t++;
}
cout<<t;
} 直接WAAC。