package main\nimport ('bufio';'fmt';'os';'strconv';'strings')\nfunc main() {\n\treader := bufio.NewReader(os.Stdin)\n\tl, _, _ := reader.ReadLine()\n\tvar t, n, s, m int\n\tt, _ = strconv.Atoi(string(l))\n\tfor i := 0; i < t; i++ {\n\t\tl, _, _ = reader.ReadLine()\n\t\tnumStr := strings.Split(string(l), ' ')\n\t\tnums := []int{}\n\t\tfor _, numStr := range numStr {\n\t\t\tnum, _ := strconv.Atoi(numStr)\n\t\t\tnums = append(nums, num)\n\t\t}\n\t\tn, s = nums[0], nums[1]\n\t\tfor j := 0; j < n; j++ {\n\t\t\tm = nums[j+2]\n\t\t\ts -= m\n\t\t}\n\t\tif s == 0 {\n\t\t\tfmt.Println('YES')\n\t\t} else {\n\t\t\tfmt.Println('NO')\n\t\t}\n\t}\n}

Go 编程:解决 bufio.NewScanner.Text() 类型错误并优化代码

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

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