Hustlingbeast_Anish

Untitled

Mar 9th, 2022
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.75 KB | None | 0 0
  1.  
  2. #include <bits/stdc++.h>
  3. #include <algorithm>
  4. #define lli long long int
  5. #define li long int
  6. #define mod 1000000007
  7. #define ld long double
  8. #define vi vector<int>
  9. #define F first
  10. #define S second
  11. #define PB push_back
  12. #define MP make_pair
  13. #define REP(i, a, b) for (int i = a; i < b; i++)
  14. using namespace std;
  15.  
  16. int main()
  17. {
  18.     ios_base::sync_with_stdio(false);
  19.     cin.tie(NULL);
  20.  
  21.     ld n, k;
  22.     cin >> n >> k;
  23.  
  24.     ld a = floor(k / n);
  25.  
  26.     ld ans = k + a;
  27.  
  28.     ld t = floor(ans / n);
  29.  
  30.     ld u = t - a;
  31.  
  32.     while (u > 0)
  33.     {
  34.         ans = ans + u;      // 112 //113
  35.         a = a + u;          // 15 //16
  36.         t = floor(ans / k); // 16 //16
  37.         u = t - a;          // 1 //0
  38.     }
  39.     cout << ans << endl;
  40.     return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment