Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
854 B
10
Indexable
inputstring = input()
input_list = inputstring.split(',')
output_list = []

for num_str in input_list:
    num=int(num_str)
    if num>0:
        sqrt_num = int(num ** 0.5)
        if sqrt_num * sqrt_num == num:
            fact = 1
            for i in range(1, num + 1):
                fact *= i

            fact_str = str(fact)
            zeros_count = 0

            for i in range(len(fact_str)-1,-1,-1):
                if fact_str[i] == '0':
                    zeros_count += 1
                else:
                    break
            if zeros_count > 0:
                num = int(fact_str[-(zeros_count + 3):-zeros_count])
                output_list.append(str(num))
            else:
                output_list.append(fact_str[-3:])
if not output_list:
    print("-1")
else:
    output_str = ','.join(output_list)
    print(output_str)