jakaria_hossain

codeforces - k-th not divisible by n

May 10th, 2020
57
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define fast()(ios_base::sync_with_stdio(0),cin.tie(NULL));
  5. int main()
  6. {
  7. ll t;
  8. cin>>t;
  9. while(t--)
  10. {
  11. ll n,k;
  12. cin>>n>>k;
  13. ll x= k/(n-1);
  14. x*=n;
  15. if(k%(n-1)==0)x-=1;
  16. else x+=(k%(n-1));
  17. if(k<n)x=k;
  18. cout<<x<<endl;
  19. }
  20.  
  21.  
  22. }
RAW Paste Data