結果
問題 |
No.41 貯金箱の溜息(EASY)
|
ユーザー |
|
提出日時 | 2025-06-15 15:42:46 |
言語 | Kotlin (2.1.0) |
結果 |
AC
|
実行時間 | 533 ms / 5,000 ms |
コード長 | 3,625 bytes |
コンパイル時間 | 16,688 ms |
コンパイル使用メモリ | 483,680 KB |
実行使用メモリ | 65,592 KB |
最終ジャッジ日時 | 2025-06-15 15:43:06 |
合計ジャッジ時間 | 17,487 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 2 |
ソースコード
import java.io.BufferedOutputStream import java.io.IOException import java.io.InputStream import java.io.PrintWriter import java.util.* import kotlin.math.* import java.math.BigInteger val singleTest: Boolean = true fun solve() { val MOD: Long = 1_000_000_009 val LIM: Int = 100_010 val dp = LongArray(LIM){1} for(i in 1 until 10){ for(j in i until LIM){ dp[j]=(dp[j]+dp[j-i])%MOD } } val n = ni() val arr = nextLongArray(n) for(idx in arr){ val j = (idx/111111).toInt() println(dp[j]) } } fun main() { val numOfTests = if (singleTest) 1 else ni() for (test in 1.. numOfTests) solve() out.flush() } // reader and writer template class FastScanner(private val stream: InputStream) { private val buf = ByteArray(1024) private var curChar = 0 private var numChars = 0 private fun read(): Int { if (numChars == -1) throw Exception("Input miss match!") if (curChar >= numChars) { curChar = 0 try { numChars = stream.read(buf) } catch (e: IOException) { throw Exception("Input miss match!") } if (numChars <= 0) return -1 } return buf[curChar++].toInt() } fun nextInt(): Int = nextLong().toInt() fun nextLong(): Long { var c = read() while (isWhitespace(c)) c = read() var negative = false if (c == '-'.code) { negative = true c = read() } var res: Long = 0 do { if (c < '0'.code || c > '9'.code) throw Exception("Input miss match!") res = res * 10 + (c - '0'.code) c = read() } while (!isWhitespace(c)) return if (negative) -res else res } fun nextDouble(): Double = next().toDouble() fun nextChar(): Char { var c = read() while (isWhitespace(c)) c = read() return c.toChar() } fun next(): String { var c = read() while (isWhitespace(c)) c = read() val res = StringBuilder() do { res.appendCodePoint(c) c = read() } while (!isWhitespace(c)) return res.toString() } private fun isWhitespace(c: Int): Boolean = c == ' '.code || c == '\n'.code || c == '\r'.code || c == '\t'.code || c == -1 } val scanner = FastScanner(System.`in`) var out = PrintWriter(BufferedOutputStream(System.`out`)) fun ni() = scanner.nextInt() fun nl() = scanner.nextLong() fun nd() = scanner.nextDouble() fun nc() = scanner.nextChar() fun ns() = scanner.next() fun nextIntArray(n: Int) = Array(n) { ni() } fun nextLongArray(n: Int) = Array(n) { nl() } fun nextDoubleArray(n: Int) = Array(n) { nd() } fun nextCharArray(n: Int) = Array(n) { scanner.nextChar() } fun nextIntGrid(n: Int, m: Int) = Array(n) { nextIntArray(m) } fun nextLongGrid(n: Int, m: Int) = Array(n) { nextLongArray(m) } fun nextDoubleGrid(n: Int, m: Int) = Array(n) { nextDoubleArray(m) } fun nextCharGrid(n: Int, m: Int) = Array(n) { nextCharArray(m)} fun print(array: Array<Int>) = out.println(array.joinToString(" ")) fun print(array: Array<Long>) = out.println(array.joinToString(" ")) fun print(array: Array<Double>) = out.println(array.joinToString(" ")) fun print(array: IntArray) = out.println(array.joinToString(" ")) fun print(array: LongArray) = out.println(array.joinToString(" ")) fun print(array: DoubleArray) = out.println(array.joinToString(" ")) fun print(list: List<Any>) = out.println(list.joinToString(" ")) fun print(obj: Any) = out.println(obj.toString())