TJCU ‘篮球杯’第一次集训比赛 Solution
用Go写的= =,有点艰难了,应该先用cpp写完再对着用Go改改
A. 签到题?
Solution
1 2 3 4 5 6 7 8 9 func sol () { var n, m, x, y int fmt.Scan(&n, &m, &x, &y) if n-m >= y-x && x <= y { fmt.Println("Yes" ) } else { fmt.Println("No" ) } }
B.这才是签到题
Solution
1 2 3 4 5 6 7 func sol () { var n, x, y int fmt.Scan(&n, &x, &y) max := min(x, y) min := max(0 , x + y - n) fmt.Println(max, min) }
C.送分题?
Solution 做过好久的NOIP真题来着,纯模拟
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 func sol () { var L, M int fmt.Scan(&L, &M) trees := make ([]bool , L+1 ) for i := 0 ; i <= L; i++ { trees[i] = true } for i := 0 ; i < M; i++ { var head, end int fmt.Scan(&head, &end) for j := head; j <= end; j++ { trees[j] = false } } rtree := 0 for i := 0 ; i <= L; i++ { if trees[i] { rtree++ } } fmt.Println(rtree) }
D.这才是送分题
Solution 原本想直接全部*
就行了,但又想到会有0,1的情况,那还是老老实实把四种情况都写上然后比max
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 func sol (a, b, c int ) { x := make ([]int , 4 ) x[0 ] = a + b + c x[1 ] = a * b * c x[2 ] = (a + b) * c x[3 ] = a * (b + c) maxNum := x[0 ] for i := 1 ; i < 4 ; i++ { if x[i] > maxNum { maxNum = x[i] } } fmt.Println(maxNum) }
E.发挥想象力 写过了,Submit区有自动保存的记录,没看
F.字符串入门
Solution 纯大分模拟,要注意最后$a[i-1]$是大于等于$a[i+1]$的情况,不是$a[i]$,直接卡180分了
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 func sol () { fmt.Print(string (a[0 ])) for i := 1 ; i < len (a)-1 ; i++ { if a[i] != '-' || (a[i+1 ]-a[i-1 ] >= 26 && a[i] == '-' ) || (a[i] == '-' && a[i-1 ] == '-' ) { fmt.Print(string (a[i])) } else { if a[i-1 ] < a[i+1 ] && a[i+1 ]-a[i-1 ] <= 25 { x, y := a[i-1 ], a[i+1 ] if s1 == 3 { for j := x + 1 ; j < y; j++ { for k := 0 ; k < s2; k++ { fmt.Print("*" ) } } } else { if s3 == 1 { for j := x + 1 ; j < y; j++ { for k := 0 ; k < s2; k++ { if s1 == 2 && y > '9' { fmt.Print(string (j - 32 )) } else { fmt.Print(string (j)) } } } } else if s3 == 2 { for j := y - 1 ; j > x; j-- { for k := 0 ; k < s2; k++ { if s1 == 2 && y > '9' { fmt.Print(string (j - 32 )) } else { fmt.Print(string (j)) } } } } } } if (a[i-1 ] + 1 ) == a[i+1 ] { continue } if a[i-1 ] >= a[i+1 ] { fmt.Print(string (a[i])) } } } fmt.Print(string (a[len (a)-1 ])) }
G.找好队友了吗 同E 题,没看(●’◡’●)
Overviews 总的来说,还挺简单的,虽然比往年那两次有难做一些,但是Jiely你给新人做大分模拟是不是太过了(〃>目<),我都卡了好几次