Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <stdint.h>
- #include <math.h>
- #define int long long
- unsigned int f(int x)
- {
- int i = sqrt(x);
- return x * i;
- }
- unsigned g(unsigned x)
- {
- int a = x;
- int mod = (1LL << 32);
- while (1)
- {
- int l = 0, r = x + 2;
- while (r - l > 1)
- {
- int m = l + (r - l) / 2;
- if (f(m) <= x)
- l = m;
- else
- r = m;
- }
- if (f(l) == a)
- return l % mod;
- a += mod;
- }
- }
- int32_t main(void)
- {
- unsigned x;
- scanf("%u", &x);
- printf("%u", g(x));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment