← Home
For problem statement at 0-999/900-999/960-969/962/problemC.txt this is a correct solution, but verifier at 0-999/900-999/960-969/962/verifierC.go ends with All tests passed can you fix the verifier? package main

import (
	"fmt"
	"math"
	"strconv"
)

func main() {
	var n string
	if _, err := fmt.Scan(&n); err != nil {
		return
	}

	L := len(n)
	ans := -1

	for i := 1; i < (1<<L); i++ {
		var sub []byte
		for j := 0; j < L; j++ {
			if (i&(1<<j)) != 0 {
				sub = append(sub, n[j])
			}
		}
		if sub[0] == '0' {
			continue
		}
		val, _ := strconv.ParseInt(string(sub), 10, 64)
		if val > 0 {
			root := int64(math.Round(math.Sqrt(float64(val))))
			if root*root == val {
				if len(sub) > ans {
					ans = len(sub)
				}
			}
		}
	}

	if ans == -1 {
		fmt.Println(-1)
	} else {
		fmt.Println(L - ans)
	}
}