Submission #8000647
Source Code Expand
import java.io.PrintWriter import java.util.* import java.math.* import java.lang.* import kotlin.comparisons.* val pw = PrintWriter(System.out) val MOD: Long = (1e+9 + 7).toLong() fun main(args: Array<String>) { val n = readInt() val l = Array(1000) { 1 } (2..n).forEach { var tmp = it (2..999).forEach { while (tmp != 1 && tmp % it == 0) { tmp /= it l[it]++ } } } println(l.map { it.toLong() }.reduce { a, b -> a * b % MOD }) pw.flush() } /****** Declared Functions and Data Structures ******/ // IO fun read() = readLine()!! fun readInt() = read().toInt() fun readLong() = read().toLong() fun readDouble() = read().toDouble() fun readListOfString() = read().split(" ") fun readListOfInt() = readListOfString().map { it.toInt() } fun readListOfLong() = readListOfString().map { it.toLong() } fun readListOfDouble() = readListOfString().map { it.toDouble() } fun Double.format(digits: Int) = String.format("%.${digits}f", this) fun Float.format(digits: Int) = String.format("%.${digits}f", this) fun print(value: Any) { pw.print(value) } fun println(value : Any) { pw.println(value) } // Extensions fun<T> List<T>.toBuckets(): Map<T, Int> = this.groupBy { it }.mapValues { it.value.size } fun<T: Comparable<T>> List<T>.upperBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int { var l = fromIndex var r = toIndex while(l < r) { val mid = (l+r) / 2 if(element >= this[mid]) { l = mid + 1 } else { r = mid } } return l } fun<T: Comparable<T>> List<T>.lowerBound(element: T, fromIndex: Int=0, toIndex: Int=this.size): Int { var l = fromIndex var r = toIndex while(l < r) { val mid = (l+r) / 2 if(element <= this[mid]) { r = mid } else { l = mid + 1 } } return r } fun <K, V> Map<K, V>.toMutableMap(): MutableMap<K, V> = HashMap(this) // Util Functions fun Long.makeDivisors(): List<Long> { val divisors = mutableListOf<Long>() for(i in 1L .. Math.sqrt(this.toDouble()).toLong()+1L) { if(this % i == 0L) { divisors.add(i) if(i != this/i) { divisors.add(this/i) } } } return divisors.distinct().sorted() } fun Long.isPrime(): Boolean { if(this==1L) return false for(i in 2L .. Math.sqrt(this.toDouble()).toLong() + 1L) { if(this % i == 0L && this != i) { return false } } return true } fun<T> permutations(src: List<T>): List<List<T>> { if(src.size == 1) return listOf(src) val perms = mutableListOf<List<T>>() val insertElement = src[0] permutations(src.drop(1)).forEach { perm -> for(i in 0..perm.size) { val newPerm = perm.toMutableList() newPerm.add(i, insertElement) perms.add(newPerm.toList()) } } return perms } // return nCr, if you want nCr, please access v[n][r] fun combinations(n: Long): List<List<Long>> { val v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList() for(i in 0 until v.size) { v[i][0] = 1L v[i][i] = 1L } for(i in 0 until v.size) { for(j in 1 until i) { v[i][j] = (v[i-1][j-1] + v[i-1][j]) % MOD } } return v.map { it.toList() }.toList() } // should be a >= b fun gcd(a: Long, b: Long): Long = if(b == 0L) a else gcd(b, a % b) // shoud be a >= b fun lcm(a: Long, b: Long): Long = a / gcd(a, b) * b fun sumDigits(num_: Long): Long { var num = num_ var rtn: Long = 0 while(num != 0.toLong()) { val tmp = num % 10 rtn += tmp num /= 10 } return rtn } fun Double.isDecimal(): Boolean = ((this - Math.floor(this)) != 0.0) // Data Structures class Stack<T>(private var st: MutableList<T> = mutableListOf<T>()) { fun isEmpty() = st.isEmpty() fun top(): T = st.last() fun push(e: T) { st.add(e) } fun pop() { st = st.dropLast(1).toMutableList() } } class Queue<T>(private var que: MutableList<T> = mutableListOf<T>()) { fun isEmpty() = que.isEmpty() fun top(): T = que.first() fun push(e: T) { que.add(e) } fun pop() { que = que.drop(1).toMutableList() } }
Submission Info
Submission Time | |
---|---|
Task | C - Factors of Factorial |
User | pokotsun |
Language | Kotlin (1.0.0) |
Score | 300 |
Code Size | 4047 Byte |
Status | AC |
Exec Time | 236 ms |
Memory | 32252 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 300 / 300 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample_01.txt, sample_02.txt, sample_03.txt |
All | sample_01.txt, sample_02.txt, sample_03.txt, subtask_1_certain_01.txt, subtask_1_certain_02.txt, subtask_1_certain_03.txt, subtask_1_certain_04.txt, subtask_1_rand_01.txt, subtask_1_rand_02.txt, subtask_1_rand_03.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
sample_01.txt | AC | 204 ms | 29756 KB |
sample_02.txt | AC | 206 ms | 31744 KB |
sample_03.txt | AC | 232 ms | 31884 KB |
subtask_1_certain_01.txt | AC | 202 ms | 31680 KB |
subtask_1_certain_02.txt | AC | 203 ms | 31732 KB |
subtask_1_certain_03.txt | AC | 233 ms | 30104 KB |
subtask_1_certain_04.txt | AC | 233 ms | 32252 KB |
subtask_1_rand_01.txt | AC | 230 ms | 29936 KB |
subtask_1_rand_02.txt | AC | 236 ms | 30140 KB |
subtask_1_rand_03.txt | AC | 233 ms | 31848 KB |