← Home
For problem statement at 1000-1999/1200-1299/1200-1209/1207/problemF.txt this is a correct solution, but verifier at 1000-1999/1200-1299/1200-1209/1207/verifierF.go ends with All 100 tests passed can you fix the verifier? package main

import (
	"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
		}
		sign := 1
		if buffer[pos] == '-' {
			sign = -1
			pos++
		}
		res := 0
		for pos < len(buffer) && buffer[pos] > ' ' {
			res = res*10 + int(buffer[pos]-'0')
			pos++
		}
		return res * sign
	}

	q := nextInt()
	const B = 700
	var sumMod [B + 1][B + 1]int
	var a [500005]int

	var out []byte
	for i := 0; i < q; i++ {
		t := nextInt()
		x := nextInt()
		y := nextInt()

		if t == 1 {
			a[x] += y
			for m := 1; m <= B; m++ {
				sumMod[m][x%m] += y
			}
		} else {
			var sum int
			if x <= B {
				sum = sumMod[x][y]
			} else {
				start := y
				if start == 0 {
					start += x
				}
				for j := start; j <= 500000; j += x {
					sum += a[j]
				}
			}
			if sum == 0 {
				out = append(out, '0')
			} else {
				if sum < 0 {
					out = append(out, '-')
					sum = -sum
				}
				var rev [20]byte
				p := 0
				for sum > 0 {
					rev[p] = byte(sum%10) + '0'
					sum /= 10
					p++
				}
				for j := p - 1; j >= 0; j-- {
					out = append(out, rev[j])
				}
			}
			out = append(out, '\n')
		}
	}
	os.Stdout.Write(out)
}