|
|
@@ -0,0 +1,63 @@
|
|
|
+package main
|
|
|
+
|
|
|
+import (
|
|
|
+ "bufio"
|
|
|
+ "strconv"
|
|
|
+ "strings"
|
|
|
+)
|
|
|
+
|
|
|
+// Pair ...
|
|
|
+type Pair struct {
|
|
|
+ _1 int
|
|
|
+ _2 int
|
|
|
+}
|
|
|
+
|
|
|
+// Pair64 ...
|
|
|
+type Pair64 struct {
|
|
|
+ _1 int64
|
|
|
+ _2 int64
|
|
|
+}
|
|
|
+
|
|
|
+// ReadLine ...
|
|
|
+func ReadLine(s *bufio.Scanner) string {
|
|
|
+ s.Scan()
|
|
|
+ return s.Text()
|
|
|
+}
|
|
|
+
|
|
|
+// ReadInt ...
|
|
|
+func ReadInt(s *bufio.Scanner) int {
|
|
|
+ s.Scan()
|
|
|
+ i, _ := strconv.ParseInt(s.Text(), 10, 32)
|
|
|
+ return int(i)
|
|
|
+}
|
|
|
+
|
|
|
+// ReadInt64 ...
|
|
|
+func ReadInt64(s *bufio.Scanner) int64 {
|
|
|
+ s.Scan()
|
|
|
+ i, _ := strconv.ParseInt(s.Text(), 10, 64)
|
|
|
+ return i
|
|
|
+}
|
|
|
+
|
|
|
+// ReadInts ...
|
|
|
+func ReadInts(s *bufio.Scanner) []int {
|
|
|
+ s.Scan()
|
|
|
+ strs := strings.Split(s.Text(), " ")
|
|
|
+ nums := make([]int, len(strs))
|
|
|
+ for i, str := range strs {
|
|
|
+ num, _ := strconv.ParseInt(str, 10, 32)
|
|
|
+ nums[i] = int(num)
|
|
|
+ }
|
|
|
+ return nums
|
|
|
+}
|
|
|
+
|
|
|
+// ReadInt64s ...
|
|
|
+func ReadInt64s(s *bufio.Scanner) []int64 {
|
|
|
+ s.Scan()
|
|
|
+ strs := strings.Split(s.Text(), " ")
|
|
|
+ nums := make([]int64, len(strs))
|
|
|
+ for i, str := range strs {
|
|
|
+ num, _ := strconv.ParseInt(str, 10, 64)
|
|
|
+ nums[i] = num
|
|
|
+ }
|
|
|
+ return nums
|
|
|
+}
|