Skip to content

Commit 7315ec7

Browse files
committed
CF25A
1 parent a4e39a1 commit 7315ec7

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

main/1-99/25A.go

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

main/1-99/25A_test.go

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

0 commit comments

Comments
 (0)