結果
| 問題 | No.542 1円玉と5円玉 |
| コンテスト | |
| ユーザー |
R_F
|
| 提出日時 | 2017-12-14 11:56:30 |
| 言語 | Kotlin (2.3.20) |
| 結果 |
AC
|
| 実行時間 | 269 ms / 2,000 ms |
| コード長 | 925 bytes |
| 記録 | |
| コンパイル時間 | 9,287 ms |
| コンパイル使用メモリ | 477,816 KB |
| 実行使用メモリ | 57,828 KB |
| 最終ジャッジ日時 | 2026-05-14 16:01:01 |
| 合計ジャッジ時間 | 13,441 ms |
|
ジャッジサーバーID (参考情報) |
judge2_1 / judge1_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 10 |
ソースコード
import java.util.Scanner
class No542() {
var input = Scanner(System. `in`)
var oneYenCount = input.nextInt()
var fiveYenCount = input.nextInt()
var oneYenList = yenCount(oneYenCount, 1)
var fiveYenList = yenCount(fiveYenCount, 5)
var list = fullSearch()
fun yenCount(count: Int, plus: Int): MutableList<Int> {
var sum = plus
var list: MutableList<Int> = mutableListOf()
for (i in 0..count - 1) {
list.add(sum)
sum += plus
}
return list
}
fun fullSearch(): MutableList<Int> {
var list: MutableList<Int> = mutableListOf()
for (i in 0..oneYenCount - 1) {
for (j in 0..fiveYenCount - 1) {
oneYenList[i] += fiveYenList[j]
list.add(oneYenList[i])
oneYenList[i] -= fiveYenList[j]
}
}
return list
}
}
fun main(args: Array<String>) {
var no542 = No542()
var result = (no542.list + no542.oneYenList + no542.fiveYenList).distinct().sorted()
result.forEach {
println(it)
}
}
R_F