T3000

Untitled

Nov 10th, 2021
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. long long t,p,r,f,y,x;
  8. cin>>t;
  9.  
  10. while(t!=0)
  11. {
  12. cin>>r>>p>>f;
  13.  
  14. if(r==1)
  15. {
  16. y=1;
  17. while(f>p)
  18. {
  19. x=p;
  20. p=p+x;
  21. y=y+1;
  22. }
  23. }
  24. else
  25. {
  26. y=0;
  27. while(f>=p)
  28. {
  29. p=r*p;
  30. y=y+1;
  31. }
  32. }
  33.  
  34. cout<<y<<endl;
  35. t=t-1;
  36. }
  37. return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment