Saleh127

Untitled

May 9th, 2020
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define inf 100000000000
  5. void solution()
  6. {
  7. ll n,k;
  8. cin>>n>>k;
  9. ll hi=inf,lo=1;
  10. ll mid,temp,ans;
  11. while(hi>=lo)
  12. {
  13. mid=(hi+lo)/2;
  14. temp=mid/n;
  15. temp=(mid-temp);
  16. if(temp>=k)
  17. {
  18. ans=mid;
  19. hi=mid-1;
  20. }
  21. else
  22. {
  23. lo=mid+1;
  24. }
  25. }
  26. cout<<ans<<endl;
  27. }
  28. int main()
  29. {
  30. ll t;
  31. cin>>t;
  32. while(t--)
  33. {
  34. solution();
  35. }
  36. return 0;
  37. }
Add Comment
Please, Sign In to add comment