Test instructions
Give a number n, and then give the number of N, indicating the number of decimal places, the number of digits after the root of the numbers is this n number, to find the most decimal place to meet such conditions.
Input:
3
123
Output:
17
Analysis:
If x.123 ... If the square of this number is an integer, it must
SQR (x.124) > Ceil (SQR (x.123)) [SQR = squared, Ceil = rounding up]
So, it is possible to enumerate its integer part X from small to large, and encounter the first x that satisfies the result, which is the answer.
Code:
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
Long long l,n;
Double a[]={1,1e-1,1e-2,1e-3,1e-4,1e-5,1e-6,1e-7,1e-8,1e-9};
int main ()
{
scanf ("%i64d%i64d", &l,&n);
Double x=n*a[l];
For (long long i=1;; i++)
{
double p=x+i;
Double c= (P+a[l]) * (P+a[l]);
Double b= (Long Long) (p*p) +1;
if (c>b)
{
printf ("%i64d\n", (Long Long) b);
break;
}
}
return 0;
}