結果
| 問題 | No.1281 Cigarette Distribution | 
| コンテスト | |
| ユーザー |  rutilicus | 
| 提出日時 | 2020-11-07 21:54:37 | 
| 言語 | Kotlin (2.1.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 558 ms / 2,000 ms | 
| コード長 | 828 bytes | 
| コンパイル時間 | 10,877 ms | 
| コンパイル使用メモリ | 444,784 KB | 
| 実行使用メモリ | 64,068 KB | 
| 最終ジャッジ日時 | 2024-07-22 14:51:31 | 
| 合計ジャッジ時間 | 20,910 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 23 | 
コンパイルメッセージ
Main.kt:14:17: warning: 'appendln(Long): kotlin.text.StringBuilder /* = java.lang.StringBuilder */' is deprecated. Use appendLine instead. Note that the new method always appends the line feed character '\n' regardless of the system line separator.
        builder.appendln(pow(moreNum, moreBox, mod) * pow(lessNum, lessBox, mod) % mod * (lessNum - 1L) % mod)
                ^
            
            ソースコード
fun main() {
    val builder = StringBuilder()
    // 解説読んだ
    val mod = 1000000007L
    val (n, m) = readInputLine().split(" ").map { it.toLong() }
    for (i in LongRange(1L, m)) {
        val moreNum = (n + 1L) / i + 1L
        val lessNum = moreNum - 1L
        val moreBox = (n + 1L) % i
        val lessBox = i - moreBox - 1L
        builder.appendln(pow(moreNum, moreBox, mod) * pow(lessNum, lessBox, mod) % mod * (lessNum - 1L) % mod)
    }
    print(builder.toString())
}
fun readInputLine(): String {
    return readLine()!!
}
fun pow(x: Long, n: Long, mod: Long): Long {
    var ret = 1L
    var base = x
    var nTmp = n
    while (nTmp != 0L) {
        if (nTmp % 2L != 0L) {
            ret = ret * base % mod
        }
        base = base * base % mod
        nTmp /= 2L
    }
    return ret
}
            
            
            
        