For problem statement at 1000-1999/1400-1499/1430-1439/1436/problemF.txt this is a correct solution, but verifier at 1000-1999/1400-1499/1430-1439/1436/verifierF.go ends with wrong answer on test 1
input:
5
20 1
55 9
10 7
42 6
72 7
expected:
291208508
got:
223145384
exit status 1 can you fix the verifier? ```go
package main
import (
"bufio"
"fmt"
"os"
)
func power(base, exp int64) int64 {
res := int64(1)
base %= 998244353
for exp > 0 {
if exp%2 == 1 {
res = res * base % 998244353
}
base = base * base % 998244353
exp /= 2
}
return res
}
func main() {
scanner := bufio.NewScanner(os.Stdin)
scanner.Split(bufio.ScanWords)
buf := make([]byte, 1024*1024)
scanner.Buffer(buf, 1024*1024*10)
scanInt := func() int {
scanner.Scan()
res := 0
for _, b := range scanner.Bytes() {
res = res*10 + int(b-'0')
}
return res
}
scanInt64 := func() int64 {
scanner.Scan()
res := int64(0)
for _, b := range scanner.Bytes() {
res = res*10 + int64(b-'0')
}
return res
}
if !scanner.Scan() {
return
}
m := 0
for _, b := range scanner.Bytes() {
m = m*10 + int(b-'0')
}
var cnt [100005]int64
maxA := 0
for i := 0; i < m; i++ {
a := scanInt()
f := scanInt64()
cnt[a] += f
if a > maxA {
maxA = a
}
}
mu := make([]int64, maxA+1)
primes := make([]int, 0)
isPrime := make([]bool, maxA+1)
for i := 2; i <= maxA; i++ {
isPrime[i] = true
}
mu[1] = 1
for i := 2; i <= maxA; i++ {
if isPrime[i] {
primes = append(primes, i)
mu[i] = -1
}
for _, p := range primes {
if i*p > maxA {
break
}
isPrime[i*p] = false
if i%p == 0 {
mu[i*p] = 0
break
} else {
mu[i*p] = -mu[i]
}
}
}
ans := int64(0)
inv8 := int64(873463809)
P := int64(998244353)
P1 := P - 1
for d := 1; d <= maxA; d++ {
if mu[d] == 0 {
continue
}
Nd := int64(0)
S1 := int64(0)
S2 := int64(0)
for i := d; i <= maxA; i += d {
if cnt[i] > 0 {
Nd += cnt[i]
val := int64(i)
cF := cnt[i] % P
S1 = (S1 + val*cF) % P
S2 = (S2 + (val*val%P)*cF) % P
}
}
if Nd == 0 {
continue
}
nModP := Nd % P
nModP1 := Nd % P1
pow2 := power(2, nModP1)
term1 := (nModP - 2 + P) % P * S2 % P
term2 := nModP * S1 % P * S1 % P
Ed := pow2 * inv8 % P * ((term1 + term2) % P) % P
if mu[d] == 1 {
ans = (ans + Ed) % P
} else if mu[d] == -1 {
ans = (ans - Ed + P) % P
}
}
fmt.Println(ans)
}
```