Skip to content

Commit cba0d3e

Browse files
committed
CF467B
1 parent ac7417a commit cba0d3e

File tree

2 files changed

+72
-0
lines changed

2 files changed

+72
-0
lines changed

main/400-499/467B.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package main
2+
3+
import (
4+
"bufio"
5+
. "fmt"
6+
"io"
7+
"math/bits"
8+
)
9+
10+
// github.com/EndlessCheng/codeforces-go
11+
func CF467B(_r io.Reader, out io.Writer) {
12+
in := bufio.NewReader(_r)
13+
var n, m, k, v, ans uint
14+
Fscan(in, &n, &m, &k)
15+
a := make([]uint, m)
16+
for i := range a {
17+
Fscan(in, &a[i])
18+
}
19+
Fscan(in, &v)
20+
21+
for _, w := range a {
22+
if uint(bits.OnesCount(v^w)) <= k {
23+
ans++
24+
}
25+
}
26+
Fprint(out, ans)
27+
}
28+
29+
//func main() { CF467B(os.Stdin, os.Stdout) }

main/400-499/467B_test.go

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package main
2+
3+
import (
4+
"github.com/EndlessCheng/codeforces-go/main/testutil"
5+
"testing"
6+
)
7+
8+
// https://codeforces.com/problemset/problem/467/B
9+
// https://codeforces.com/problemset/status/467/problem/B
10+
func TestCF467B(t *testing.T) {
11+
// just copy from website
12+
rawText := `
13+
inputCopy
14+
7 3 1
15+
8
16+
5
17+
111
18+
17
19+
outputCopy
20+
0
21+
inputCopy
22+
3 3 3
23+
1
24+
2
25+
3
26+
4
27+
outputCopy
28+
3
29+
inputCopy
30+
6 8 2
31+
46
32+
59
33+
38
34+
5
35+
13
36+
54
37+
26
38+
62
39+
18
40+
outputCopy
41+
2`
42+
testutil.AssertEqualCase(t, rawText, 0, CF467B)
43+
}

0 commit comments

Comments
 (0)