forked from EndlessCheng/codeforces-go
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9497965
commit 4f47197
Showing
2 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} |