結果
問題 |
No.32 貯金箱の憂鬱
|
ユーザー |
|
提出日時 | 2018-03-10 16:13:00 |
言語 | Go (1.23.4) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 834 bytes |
コンパイル時間 | 12,898 ms |
コンパイル使用メモリ | 237,668 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-23 07:05:58 |
合計ジャッジ時間 | 13,511 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 12 |
ソースコード
package main import ( "bufio" "fmt" "os" "strconv" ) // エントリポイント func main() { in := bufio.NewScanner(os.Stdin) in.Scan() // 100 円硬貨の枚数 input1 := in.Text() in.Scan() // 25 円硬貨の枚数 input2 := in.Text() in.Scan() // 1 円硬貨の枚数 input3 := in.Text() fmt.Println(savings(input1, input2, input3)) } func savings(yen100 string, yen25 string, yen1 string) string { i1000 := 0 i100, _ := strconv.Atoi(yen100) i25, _ := strconv.Atoi(yen25) i1, _ := strconv.Atoi(yen1) if i1 != 0 { i25 += i1 / 25 // % で割り算の余りを取得 i1 = i1 % 25 } if i25 != 0 { i100 += i25 / 4 i25 = i25 % 4 } if i100 != 0 { i1000 = i100 / 10 i100 = i100 % 10 } // 硬貨の数なので、1000円札は加算しない _ = i1000 return strconv.Itoa(i100 + i25 + i1) }