fork(1) download
  1. #include <cstdio>
  2. #include <cmath>
  3.  
  4. float credit(float a, float b, float c, float x) {
  5. float n = ceil(-log(((a - 1) * x) / (b - c) + 1) / log(a));
  6. return c * n + (pow(a, n) * ((a - 1) * x + b - c) - b + c) / (a - 1);
  7. }
  8.  
  9. int main() {
  10. float a, b, c, x;
  11. scanf("%f %f %f %f", &a, &b, &c, &x);
  12. printf("%.2f", credit(a, b, c, x));
  13. return 0;
  14. }
Success #stdin #stdout 0s 3344KB
stdin
1.03 1000 5000 40000
stdout
61270.18