結果

問題 No.656 ゴルフ
ユーザー mijimemijime
提出日時 2018-03-06 07:12:10
言語 Go
(1.22.1)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 587 bytes
コンパイル時間 14,153 ms
コンパイル使用メモリ 213,856 KB
実行使用メモリ 4,368 KB
最終ジャッジ日時 2023-10-12 18:18:38
合計ジャッジ時間 12,846 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,356 KB
testcase_03 AC 1 ms
4,368 KB
testcase_04 AC 2 ms
4,352 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 2 ms
4,356 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 1 ms
4,352 KB
testcase_09 AC 1 ms
4,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

import (
	"bufio"
	"fmt"
	"io"
	"log"
	"os"

	"strconv"
	"strings"
)

func Run(in io.Reader, out io.Writer) error {
	sc := bufio.NewScanner(in)
	for sc.Scan() {
		var sum int64 = 0

		line := sc.Text()
		for _, scoreText := range strings.Split(line, "") {
			score, err := strconv.ParseInt(scoreText, 0, 64)
			if err != nil {
				log.Fatal(err)
			}
			if score == 0 {
				sum += 10
			} else {
				sum += score
			}
		}
		fmt.Fprintf(out, "%d\n", sum)
		return nil
	}

	return nil
}

func main() {
	err := Run(os.Stdin, os.Stdout)

	if err != nil {
		log.Fatal(err)
	}
}
0