A Carryless Square Root
题号:NC224724
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

Carryless addition is the same as normal addition, except any carries are ignored (in base 10). Thus, 37 + 48 is 75, not 85.

Carryless multiplication is performed using the schoolbook algorithm for multiplication, column by column, but the intermediate sums are calculated using carryless addition. Thus:
9 ∙ 1234 = 9000 + (900 + 900) + (90 + 90 + 90) + (9 + 9 + 9 + 9) = 9000 + 800 + 70 + 6 = 9876
90 ∙ 1234 = 98760
99 ∙ 1234 = 98760 + 9876 = 97536

Formally, define c_kto be the digit of the value 𝑐. If 𝑐 = 𝑎 ∙ 𝑏 then  

Given an integer 𝒏, calculate the smallest positive integer 𝒂 such that 𝒂 ∙ 𝒂 = 𝒏 in carryless multiplication. 


输入描述:

The input consists of a single line with an integer n ().

输出描述:

Output the smallest positive integer that is a carryless square root of the input number, or −1 if no such number exists.
示例1

输入

复制
6

输出

复制
4
示例2

输入

复制
149

输出

复制
17
示例3

输入

复制
123476544

输出

复制
11112
示例4

输入

复制
15

输出

复制
-1