Saleh127

codeforces 1359A.cpp

May 28th, 2020
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 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 pi acos(-1)
  6. int main()
  7. {
  8. ll n,m,k,a,c,d,e,f;
  9. test
  10. {
  11. cin>>n>>m>>k;
  12. a=n/k;
  13. if(m<=a) cout<<m<<endl;
  14. else
  15. {
  16. d=m-a;
  17. if(d%(k-1)==0) c=d/(k-1);
  18. else c=1+d/(k-1);
  19. a=a-c;
  20. cout<<a<<endl;
  21. }
  22. }
  23. return 0;
  24. }
Add Comment
Please, Sign In to add comment