24 lines
388 B
Go
24 lines
388 B
Go
// Wrong: int64 overflows, so only the group with huge numbers fails.
|
|
package main
|
|
|
|
import (
|
|
"bufio"
|
|
"fmt"
|
|
"os"
|
|
"strconv"
|
|
)
|
|
|
|
func main() {
|
|
scanner := bufio.NewScanner(os.Stdin)
|
|
scanner.Split(bufio.ScanWords)
|
|
var total int64
|
|
for scanner.Scan() {
|
|
value, err := strconv.ParseInt(scanner.Text(), 10, 64)
|
|
if err != nil {
|
|
os.Exit(2)
|
|
}
|
|
total += value
|
|
}
|
|
fmt.Println(total)
|
|
}
|