编程介的小学生 2019-09-09 19:59 采纳率: 0.4%
浏览 96

Don't be angry 程序是怎么写的

Problem Description
Wiskey buys a cake and wants to eat with Michelle. The cake is very delicious with many chocolates on it.
The cake is big; Wiskey need cut it to 6 pieces.
Michelle is a perfectionist and she sets perfect standard for Wiskey that each piece must contains the same weight of chocolates.
At first the cake may be not perfect, so Wiskey get some chocolate sticks, but the chocolate stick is too long, it will occupy adjacent two pieces and add same weight on the adjacent two pieces.
You can assume Wiskey have infinite various weight chocolate sticks.
Quick, Help Wiskey! Michelle is beginning to be angry.

Input
First line will contain one integer means how many cases will be follow.
Each line will contain six integers means the weight of chocolates at first.
All integers range in signed 32 bits.

Output
Print "YES" if Wiskey could finish the task.
Else print "NO", and then you could visit Wiskey in hospital.

Sample Input
4
1 1 1 1 1 1
1 1 1 1 1 0
1 1 1 1 0 0
2 1 0 0 1 2

Sample Output
YES
NO
YES
YES

  • 写回答

1条回答 默认 最新

  • 你知我知皆知 2024-07-30 21:38
    关注

    以下回答参考 皆我百晓生券券喵儿 等免费微信小程序相关内容作答,并由本人整理回复。

    # read data
    cases <- readLines(stdin())
    
    for (case in cases) {
      # split case into six parts
      weights <- as.numeric(strsplit(case, " ")[[1]])
      
      # check if possible to divide the cake perfectly
      if (weights[1] %in% c(0, 1)) {
        print("YES")
      } else {
        print("NO")
      }
    }
    
    评论

报告相同问题?