fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define ull unsigned long long
  5. #define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  6. #define fread(p) freopen(p,"r",stdin);
  7. #define fwrite(p) freopen(p,"w",stdout);
  8. #define pii pair<int, int>
  9. #define pll pair<ll, ll>
  10. #define pb push_back
  11. #define mem(s,k) memset(s, k, sizeof(s))
  12.  
  13. ////--- Graph Moves---////
  14. //const ll xx[] = {0,0,1,-1};
  15. //const ll yy[] = {1,-1,0,0};
  16. //const ll xx_king[] = {0,0,1,-1,1,1,-1,-1};
  17. //const ll yy_king[] = {1,-1,0,0,1,-1,1,-1};
  18. //const ll xx_knight[]= {-2,-1,1,2,2,1,-1,-2};
  19. //const ll yy_knight[]= {1,2,2,1,-1,-2,-2,-1};
  20. ////------------------////
  21.  
  22. int main()
  23. {
  24. // fwrite("a.txt");
  25. double t,s,q, cnt=0;
  26. cin >> t >> s >> q;
  27. double r=t-s, d, i,j, x=(q-1)/q;
  28. while(r>0)
  29. {
  30. // cout << "he " << r << endl;
  31. cnt++;
  32. for(i=0, j=s; i<j && r>0; )
  33. {
  34. if(i==j) break;
  35. // printf("%.12f %.12f %.6f\n",i,j,r);
  36. i++;
  37. j += x;
  38. r = t-j;
  39. }
  40. s = j;
  41. }
  42. // while(s<t)
  43. // cnt++, s*=q;
  44. cout << cnt << endl;
  45. }
  46.  
Success #stdin #stdout 0s 4444KB
stdin
Standard input is empty
stdout
0