Skip to content

Commit 9926cbf

Browse files
committed
CF1270C 构造
1 parent d84e83e commit 9926cbf

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed

main/1200-1299/1270C.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package main
2+
3+
import (
4+
"bufio"
5+
. "fmt"
6+
"io"
7+
)
8+
9+
// github.com/EndlessCheng/codeforces-go
10+
func CF1270C(_r io.Reader, _w io.Writer) {
11+
in := bufio.NewReader(_r)
12+
out := bufio.NewWriter(_w)
13+
defer out.Flush()
14+
15+
var T, n, v int64
16+
for Fscan(in, &T); T > 0; T-- {
17+
var s, xor int64
18+
for Fscan(in, &n); n > 0; n-- {
19+
Fscan(in, &v)
20+
s += v
21+
xor ^= v
22+
}
23+
Fprintln(out, 2)
24+
Fprintln(out, xor, s+xor)
25+
}
26+
}
27+
28+
//func main() { CF1270C(os.Stdin, os.Stdout) }

main/1200-1299/1270C_test.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+
"github.com/EndlessCheng/codeforces-go/main/testutil"
5+
"testing"
6+
)
7+
8+
// https://codeforces.com/problemset/problem/1270/C
9+
// https://codeforces.com/problemset/status/1270/problem/C
10+
func TestCF1270C(t *testing.T) {
11+
// just copy from website
12+
rawText := `
13+
inputCopy
14+
3
15+
4
16+
1 2 3 6
17+
1
18+
8
19+
2
20+
1 1
21+
outputCopy
22+
0
23+
24+
2
25+
4 4
26+
3
27+
2 6 2`
28+
testutil.AssertEqualCase(t, rawText, 0, CF1270C)
29+
}

0 commit comments

Comments
 (0)