Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // I can't tell you what it really is,
- // I can only tell you what it feels like.
- #include "bits/stdc++.h"
- using namespace std;
- #define int long long
- #define ld long double
- signed main() {
- ios::sync_with_stdio(false);
- cin.tie(0);
- int A, N;
- cin >> A >> N;
- ld ans = -1, lo = 1, hi = 20;
- const ld inf = 1e-14;
- const ld preLog = log(A);
- // cout << preLog << '\n';
- while (!(hi-lo<=inf)) {
- ld mid = (lo+hi)/2.0;
- // cout << N*log(mid) << ' ' << preLog << '\n';
- if (preLog-N*log(mid) >= inf) {
- lo = mid + inf;
- ans = mid;
- }
- else hi = mid - inf;
- }
- cout << fixed << setprecision(10) << ans;
- return 0;
- }
- // 1). Try forming/rearranging the equations if any
- // 2). If problem asks to count, try counting in reverse(it can be easier sometimes)
Add Comment
Please, Sign In to add comment