题解 | #序列找数#
序列找数
https://www.nowcoder.com/practice/a7d1856a72404ea69fdfb5786d65539c
package main import "fmt" import "os" import "bufio" import "strconv" import "strings" func main(){ input := bufio.NewScanner(os.Stdin) input.Scan() numlist:= strings.Split(input.Text()," ") maxnum,_:= strconv.Atoi(numlist[0]) sum :=0 for k:=1;k<len(numlist);k++{ index,_ := strconv.Atoi(numlist[k]) sum +=index } for i:=1;i<=maxnum;i++{ sum -=i } fmt.Println(-sum) }