12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- 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
- }
- func maxInt(x, y int) int {
- if y < x {
- return x
- }
- return y
- }
|