Saleh127

UVA 11313

Jul 7th, 2020
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define test int t; cin>>t; while (t--)
  4. #define ll long long int
  5. #define fellow_junior ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  6. int main()
  7. {
  8. fellow_junior
  9. ll n,m,a,c,d,i,j,k,l;
  10. test
  11. {
  12. cin>>n>>m;
  13. c=0;
  14. while(n>=m)
  15. {
  16. n-=(m-1);
  17. c++;
  18. }
  19. if(n>1) cout<<"cannot do this"<<endl;
  20. else cout<<c<<endl;
  21. }
  22. return 0;
  23. }
  24. /*
  25. another process
  26. if ((n - 1) % (m - 1) != 0)
  27. {
  28. puts("cannot do this");
  29. }
  30. else
  31. {
  32. printf("%d\n", (n - 1) / (m - 1));
  33. }
  34. ////
  35.  
  36.  
  37. while(n>=m)
  38. {
  39. int temp = n%m;
  40. d= n/m;
  41. count+=d;
  42. n=d+temp;
  43. }
  44. //cout<<n<<" ";
  45. if(n>1)
  46. {
  47. printf("cannot do this\n");
  48. }
  49. else
  50. {
  51. printf("%d\n",count);
  52. }
  53. */
Advertisement
Add Comment
Please, Sign In to add comment