To find a number y that satisfies the given condition, we can iterate through all possible values of y from 0 to 10^9 and check if the square of y starts with the given xxx.

Here is the implementation in Python:

def find_number(t, x):
    for i in range(t):
        found = False
        for y in range(10**9 + 1):
            if str(y**2).startswith(str(x[i])):
                print(y)
                found = True
                break
        if not found:
            print(-1)

# Read the number of test cases
t = int(input())

# Read the values of x
x = []
for _ in range(t):
    x.append(int(input()))

# Find the number y for each test case
find_number(t, x)

For example, if the input is:

5
1
4
9
16
25

The output will be:

1
20
3
4
5

Note that there can be multiple valid solutions for each test case, so the output may vary

Find a number 0≤y≤1090 leq yleq 10^90≤y≤109 so that the square of yyy starts with xxx in DecimalFormally given a integer xxx find an integer yyy0≤y≤1090 leq yleq 10^90≤y≤109 such that there exists a n

原文地址: http://www.cveoy.top/t/topic/ieON 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录