package main import ( "bufio" "fmt" "os" ) func main() { reader := bufio.NewReader(os.Stdin) l, _, _ := reader.ReadLine() var t, n, s, m int fmt.Sscanf(string(l), "%d", &t) for i := 0; i < t; i++ { l, _, _ = reader.ReadLine() fmt.Sscanf(string(l), "%d%d", &n, &s) for j := 0; j < n; j++ { fmt.Fscanf(reader, "%d", &m) s -= m } fmt.Println(s) if s == 0 { fmt.Println('YES') } else { fmt.Println('NO') } } }//还有错内容:在第一个fmt.Println(s)语句之后,可以添加一个条件判断来确定输出'YES'还是'NO':

if s == 0 {
    fmt.Println('YES')
} else {
    fmt.Println('NO')
}

这样就可以根据变量s的值输出相应的结果。

Go 语言实现简单判断:测试用例是否满足条件

原文地址: https://www.cveoy.top/t/topic/pCAJ 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录