結果
問題 | No.32 貯金箱の憂鬱 |
ユーザー | gogotea |
提出日時 | 2015-04-29 12:19:15 |
言語 | Go1.4 (1.4.2) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 1,065 bytes |
コンパイル時間 | 1,901 ms |
コンパイル使用メモリ | 34,760 KB |
実行使用メモリ | 4,380 KB |
最終ジャッジ日時 | 2023-09-30 07:49:54 |
合計ジャッジ時間 | 2,637 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge15 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,376 KB |
testcase_01 | AC | 1 ms
4,380 KB |
testcase_02 | AC | 1 ms
4,376 KB |
testcase_03 | AC | 1 ms
4,376 KB |
testcase_04 | AC | 1 ms
4,380 KB |
testcase_05 | AC | 1 ms
4,376 KB |
testcase_06 | AC | 1 ms
4,380 KB |
testcase_07 | AC | 2 ms
4,380 KB |
testcase_08 | AC | 1 ms
4,376 KB |
testcase_09 | AC | 1 ms
4,376 KB |
testcase_10 | AC | 1 ms
4,376 KB |
testcase_11 | AC | 1 ms
4,376 KB |
ソースコード
package main import ( "bufio" "fmt" "io" "os" "strconv" ) // 未実装 func main() { sc := NewScanner(os.Stdin) L, _ := sc.NextInt() //100円硬貨 M, _ := sc.NextInt() //25円硬貨 N, _ := sc.NextInt() //1円硬貨 fmt.Println(solve(L, M, N)) } func solve(l, m, n int) int { total := l*100 + m*25 + n coins := [...]int{1000, 100, 25} sum := 0 for _, coin := range coins { if total >= coin { a := total / coin if coin != 1000 { sum += a } total -= coin * a } } return sum + total } type Scanner struct { *bufio.Scanner } func NewScanner(r io.Reader) *Scanner { return &Scanner{ bufio.NewScanner(r), } } func (s *Scanner) Next() (string, error) { s.Scanner.Split(bufio.ScanWords) return s.nextToken() } func (s *Scanner) nextToken() (string, error) { sc := s.Scanner if sc.Scan() { return sc.Text(), nil } if sc.Err() != nil { return "", sc.Err() } return "", io.EOF } func (s *Scanner) NextInt() (int, error) { token, err := s.Next() if err != nil { return 0, err } return strconv.Atoi(token) }