Skip to content

Commit 0393af9

Browse files
committed
CF1455B
1 parent 4f50bc8 commit 0393af9

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed

main/1400-1499/1455B.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+
)
8+
9+
// github.com/EndlessCheng/codeforces-go
10+
func CF1455B(_r io.Reader, _w io.Writer) {
11+
in := bufio.NewReader(_r)
12+
out := bufio.NewWriter(_w)
13+
defer out.Flush()
14+
15+
var T, x int
16+
for Fscan(in, &T); T > 0; T-- {
17+
Fscan(in, &x)
18+
k := 0
19+
for ; x > 0; x -= k {
20+
k++
21+
}
22+
if x == -1 {
23+
k++
24+
}
25+
Fprintln(out, k)
26+
}
27+
}
28+
29+
//func main() { CF1455B(os.Stdin, os.Stdout) }

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

0 commit comments

Comments
 (0)