結果

問題 No.1811 EQUIV Ten
ユーザー yudedako
提出日時 2022-01-24 22:12:13
言語 Kotlin
(2.1.0)
結果
AC  
実行時間 395 ms / 2,000 ms
コード長 848 bytes
コンパイル時間 13,605 ms
コンパイル使用メモリ 437,656 KB
実行使用メモリ 82,640 KB
最終ジャッジ日時 2024-12-15 01:09:25
合計ジャッジ時間 27,861 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 33
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:22:14: warning: name shadowed: i
        for (i in 0 until 16) {
             ^
Main.kt:26:14: warning: name shadowed: i
        for (i in 0 until 16) {
             ^

ソースコード

diff #

const val MOD = 1000000007
fun powMod(base: Long, exp: Int): Long {
    var b = base % MOD
    var e = exp
    var result = 1L
    while (e > 0) {
        if ((e and 1) == 1) {
            result = result * b % MOD
        }
        b = b * b % MOD
        e = e shr 1
    }
    return result
}
fun main() {
    val n = readLine()!!.trim().toInt()
    val count = LongArray(16).also { it[0] = 1L }
    var result = 0L
    for (i in 0 until n) {
        val from = count.copyOf()
        count.fill(0)
        for (i in 0 until 16) {
            count[(i shl 1) and 15] += from[i]
            count[((i shl 1) + 1) and 15] += from[i]
        }
        for (i in 0 until 16) {
            count[i] = count[i] % MOD
        }
        result += count[10] * powMod(2L, n - i - 1) % MOD
        count[10] = 0
    }
    result %= MOD
    println(result)
}
0