o0w0o / ARTS

ARTS 鸽友打卡🐦
2 stars 0 forks source link

Educational Codeforces Round 73 (Rated for Div. 2) #135

Open hyponet opened 4 years ago

hyponet commented 4 years ago

A

2048 游戏凑 2048,但是可以有 1,所有被坑了几次:

package main

import (
    "bufio"
    "fmt"
    "os"
)

func main() {
    input := bufio.NewReader(os.Stdin)
    var (
        count int
    )
    _, _ = fmt.Fscan(input, &count)

    for count > 0 {
        count--

        var setNum int
        _, _ = fmt.Fscan(input, &setNum)

        hasAns := false
        countMap := map[uint32]int{}
        for i := 0; i < setNum; i++ {
            var num uint32
            _, _ = fmt.Fscan(input, &num)
            if num > 2048 || hasAns {
                continue
            }
            if num == 2048 {
                hasAns = true
            }
            if _, ok := countMap[num]; ok {
                countMap[num] = countMap[num] + 1
            } else {
                countMap[num] = 1
            }
        }

        if hasAns {
            fmt.Println("YES")
            continue
        }

        for i := 1; i < 2048; i *= 2 {
            if _, ok := countMap[uint32(i)]; ok {

                if _, ok := countMap[uint32(i*2)]; ok {
                    countMap[uint32(i*2)] = countMap[uint32(i)]/2 + countMap[uint32(i*2)]
                } else {
                    countMap[uint32(i*2)] = countMap[uint32(i)] / 2
                }
                countMap[uint32(i)] = countMap[uint32(i)] % 2

            } else {
                countMap[uint32(i)] = 0
            }
        }

        if countMap[uint32(2048)] > 0 {
            fmt.Println("YES")
            continue
        }
        fmt.Println("NO")

    }

}

B

黑白骑士,类似中国象棋的马,摆放让互吃的最多,其实有规律,间隔摆放就好

package main

import (
    "bufio"
    "fmt"
    "os"
)

func main() {
    input := bufio.NewReader(os.Stdin)
    var (
        n int
    )
    _, _ = fmt.Fscan(input, &n)

    needW := true
    for i := 0; i < n; i++ {
        first := needW
        for j := 0; j < n; j++ {
            if needW {
                fmt.Print("W")
            } else {
                fmt.Print("B")
            }
            needW = !needW
        }
        if first == needW {
            needW = !needW
        }
        fmt.Println()
    }
}

C

组 ACM 队伍,有编码好的有数学好的,一个队伍同时存在这两种就是完美队伍,问最多几个完美队伍,要考虑总人数是否达标:

package main

import (
    "bufio"
    "fmt"
    "os"
)

func main() {
    input := bufio.NewReader(os.Stdin)
    var (
        count int
    )
    _, _ = fmt.Fscan(input, &count)

    for count > 0 {
        count--
        var (
            coder   int
            mather  int
            useless int
        )
        _, _ = fmt.Fscan(input, &coder, &mather, &useless)

        maxTeam := coder
        if maxTeam > mather {
            maxTeam = mather
        }

        rMaxTeam := (coder + mather + useless) / 3
        if maxTeam > rMaxTeam {
            maxTeam = rMaxTeam
        }
        fmt.Println(maxTeam)
    }

}