← Home
For problem statement at 0-999/800-899/800-809/803/problemF.txt this is a correct solution, but verifier at 0-999/800-899/800-809/803/verifierF.go ends with All tests passed can you fix the verifier? package main

import (
	"fmt"
	"io"
	"os"
)

func main() {
	buffer, _ := io.ReadAll(os.Stdin)
	pos := 0
	nextInt := func() int {
		for pos < len(buffer) && buffer[pos] <= ' ' {
			pos++
		}
		if pos >= len(buffer) {
			return 0
		}
		res := 0
		for pos < len(buffer) && buffer[pos] > ' ' {
			res = res*10 + int(buffer[pos]-'0')
			pos++
		}
		return res
	}

	n := nextInt()
	if n == 0 {
		return
	}

	freq := make([]int, 100005)
	maxVal := 0
	for i := 0; i < n; i++ {
		a := nextInt()
		freq[a]++
		if a > maxVal {
			maxVal = a
		}
	}

	pow2 := make([]int, n+1)
	pow2[0] = 1
	for i := 1; i <= n; i++ {
		pow2[i] = (pow2[i-1] * 2) % 1000000007
	}

	f := make([]int, maxVal+1)
	for d := maxVal; d >= 1; d-- {
		c := 0
		for k := d; k <= maxVal; k += d {
			c += freq[k]
		}
		if c == 0 {
			continue
		}
		f[d] = pow2[c] - 1
		for k := 2 * d; k <= maxVal; k += d {
			f[d] -= f[k]
			if f[d] < 0 {
				f[d] += 1000000007
			}
		}
	}

	fmt.Println(f[1])
}