結果
問題 | No.1581 Multiple Sequence |
ユーザー | 👑 箱 |
提出日時 | 2021-07-02 22:58:45 |
言語 | Kotlin (1.9.23) |
結果 |
AC
|
実行時間 | 661 ms / 2,000 ms |
コード長 | 2,754 bytes |
コンパイル時間 | 15,284 ms |
コンパイル使用メモリ | 425,392 KB |
実行使用メモリ | 60,280 KB |
最終ジャッジ日時 | 2023-09-11 23:25:24 |
合計ジャッジ時間 | 28,526 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 274 ms
50,352 KB |
testcase_01 | AC | 269 ms
50,248 KB |
testcase_02 | AC | 568 ms
59,728 KB |
testcase_03 | AC | 603 ms
59,288 KB |
testcase_04 | AC | 391 ms
55,804 KB |
testcase_05 | AC | 625 ms
59,348 KB |
testcase_06 | AC | 436 ms
57,696 KB |
testcase_07 | AC | 374 ms
55,868 KB |
testcase_08 | AC | 403 ms
55,640 KB |
testcase_09 | AC | 587 ms
59,532 KB |
testcase_10 | AC | 490 ms
57,736 KB |
testcase_11 | AC | 354 ms
55,748 KB |
testcase_12 | AC | 413 ms
55,716 KB |
testcase_13 | AC | 295 ms
52,600 KB |
testcase_14 | AC | 607 ms
59,420 KB |
testcase_15 | AC | 497 ms
57,580 KB |
testcase_16 | AC | 367 ms
55,584 KB |
testcase_17 | AC | 661 ms
60,196 KB |
testcase_18 | AC | 336 ms
55,852 KB |
testcase_19 | AC | 581 ms
59,828 KB |
testcase_20 | AC | 565 ms
59,808 KB |
testcase_21 | AC | 612 ms
60,280 KB |
testcase_22 | AC | 483 ms
57,752 KB |
testcase_23 | AC | 661 ms
59,336 KB |
ソースコード
import java.io.PrintWriter import java.util.* fun PrintWriter.solve() { val m = nextInt() val dp = Array(m + 1) { ModInt(0) } dp[0] = ModInt(1) for (n in 1..m) { // region divisors val number = n.toLong() val divs = mutableListOf<Long>() var divisor = 1L while (divisor * divisor <= number) { if (number % divisor == 0L) { divs.add(divisor) if (divisor * divisor != number) { divs.add(number / divisor) } } divisor++ } // endregion for (_d in divs) { val d = _d.toInt() dp[n] += dp[d - 1] } } println(dp[m]) } // region ModInt class ModInt(x: Long) { companion object { const val MOD = 1000000007L //const val MOD = 998244353L } constructor(y: Int) : this(y.toLong()) val x = (x % MOD + MOD) % MOD operator fun plus(other: ModInt): ModInt { return ModInt(x + other.x) } operator fun minus(other: ModInt): ModInt { return ModInt(x - other.x) } operator fun times(other: ModInt): ModInt { return ModInt(x * other.x) } operator fun div(other: ModInt): ModInt { return this * other.inv() } fun pow(exp: Long): ModInt { if (exp == 0L) return ModInt(1L) var a = pow(exp shr 1) a *= a if (exp and 1L == 0L) return a return this * a } fun inv(): ModInt { return this.pow(MOD - 2) } override fun equals(other: Any?): Boolean { if (this === other) return true if (javaClass != other?.javaClass) return false other as ModInt if (x != other.x) return false return true } override fun hashCode(): Int { return x.hashCode() } override fun toString(): String { return "$x" } } fun Long.toModInt(): ModInt { return ModInt(this) } fun Int.toModInt(): ModInt { return ModInt(this) } fun binomSimple(n: Long, k: Long): ModInt { var numer = ModInt(1) var denom = ModInt(1) for (i in 0 until k) { numer *= ModInt(n - i) denom *= ModInt(k - i) } return numer / denom } // endregion fun main() { val writer = PrintWriter(System.out, false) writer.solve() writer.flush() } // region Scanner private var st = StringTokenizer("") private val br = System.`in`.bufferedReader() fun next(): String { while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine()) return st.nextToken() } fun nextInt() = next().toInt() fun nextLong() = next().toLong() fun nextLine() = br.readLine() fun nextDouble() = next().toDouble() // endregion