Skip to content

Commit

Permalink
CF1931D
Browse files Browse the repository at this point in the history
  • Loading branch information
EndlessCheng committed Feb 14, 2024
1 parent 9497965 commit 4f47197
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 0 deletions.
30 changes: 30 additions & 0 deletions main/1900-1999/1931D.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package main

import (
"bufio"
. "fmt"
"io"
)

// https://space.bilibili.com/206214
func cf1931D(_r io.Reader, _w io.Writer) {
in := bufio.NewReader(_r)
out := bufio.NewWriter(_w)
defer out.Flush()

var T, n, x, y, v int
for Fscan(in, &T); T > 0; T-- {
Fscan(in, &n, &x, &y)
ans := 0
type pair struct{ x, y int }
cnt := map[pair]int{}
for ; n > 0; n-- {
Fscan(in, &v)
ans += cnt[pair{(x - v%x) % x, v % y}]
cnt[pair{v % x, v % y}]++
}
Fprintln(out, ans)
}
}

//func main() { cf1931D(os.Stdin, os.Stdout) }
39 changes: 39 additions & 0 deletions main/1900-1999/1931D_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Generated by copypasta/template/generator_test.go
package main

import (
"github.com/EndlessCheng/codeforces-go/main/testutil"
"testing"
)

// https://codeforces.com/contest/1931/problem/D
// https://codeforces.com/problemset/status/1931/problem/D
func Test_cf1931D(t *testing.T) {
testCases := [][2]string{
{
`7
6 5 2
1 2 7 4 9 6
7 9 5
1 10 15 3 8 12 15
9 4 10
14 10 2 2 11 11 13 5 6
9 5 6
10 7 6 7 9 7 7 10 10
9 6 2
4 9 7 1 2 2 13 3 15
9 2 3
14 6 1 15 12 15 8 2 15
10 5 7
13 3 3 2 12 11 3 7 13 14`,
`2
0
1
3
5
7
0`,
},
}
testutil.AssertEqualStringCase(t, testCases, 0, cf1931D)
}

0 comments on commit 4f47197

Please sign in to comment.