Skip to content

Commit 8217eaf

Browse files
committed
CF1375A
1 parent 0393af9 commit 8217eaf

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed

main/1300-1399/1375A.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package main
2+
3+
import (
4+
"bufio"
5+
. "fmt"
6+
"io"
7+
)
8+
9+
// github.com/EndlessCheng/codeforces-go
10+
func CF1375A(_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 int
16+
for Fscan(in, &T); T > 0; T-- {
17+
for Fscan(in, &n); n > 0; n-- {
18+
if Fscan(in, &v); v > 0 == (n&1 > 0) {
19+
v = -v
20+
}
21+
Fprint(out, -v, " ")
22+
}
23+
Fprintln(out)
24+
}
25+
}
26+
27+
//func main() { CF1375A(os.Stdin, os.Stdout) }

main/1300-1399/1375A_test.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package main
2+
3+
import (
4+
"github.com/EndlessCheng/codeforces-go/main/testutil"
5+
"testing"
6+
)
7+
8+
// https://codeforces.com/problemset/problem/1375/A
9+
// https://codeforces.com/problemset/status/1375/problem/A
10+
func TestCF1375A(t *testing.T) {
11+
// just copy from website
12+
rawText := `
13+
inputCopy
14+
5
15+
3
16+
-2 4 3
17+
5
18+
1 1 1 1 1
19+
5
20+
-2 4 7 -6 4
21+
9
22+
9 7 -4 -2 1 -3 9 -4 -5
23+
9
24+
-4 1 9 4 8 9 5 1 -9
25+
outputCopy
26+
-2 -4 3
27+
1 1 1 1 1
28+
-2 -4 7 -6 4
29+
-9 -7 -4 2 1 -3 -9 -4 -5
30+
4 -1 -9 -4 -8 -9 -5 -1 9`
31+
testutil.AssertEqualCase(t, rawText, 0, CF1375A)
32+
}

0 commit comments

Comments
 (0)