思路:二分答案。
#include<cstdio> #include<cstring> #include<iostream> #include<algorithm> using namespace std; int a,b,c; double l,r,mid; bool judge(){ int sum=0; double k=a,mm=mid/100; for(int i=1;i<=c;i++){ k+=k*mm; k-=b; } if(k<0) return true; else return false; } int main(){ scanf("%d%d%d",&a,&b,&c); l=0;r=1000; while(r-l>=0.00001){ mid=(l+r)/2; if(judge()) l=mid+0.00001; else r=mid-0.00001; } printf("%.1lf",l); }