I am solving some tasks from school olimpiads, and I got stuck on one question. I found the solution for the task, but my solution requires square rooting. My code works fine for first 12 inputs, but then it gives wrong answers. I guess that it is due to extremely large inputs, which can be as large as 10^400000. So I would like to know if there are ways to calculate whole number parts of square roots of these extremely large inputs in C. Here is the code:
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
int main(){
long long n;
scanf("%lld", &n);
long long ans;
ans = sqrtl(n-1);
long long result;
result = ans+1-llabs(n-ans*ans-(ans+1));
printf("%lld\n", result);
return 0;
}