Submission #2551391
Source Code Expand
import java.util.Scanner import scala.collection.mutable.ArrayBuffer object Main { val MOD = 1000000007 def solve(N: Int): Long = { val f = { val f: ArrayBuffer[Int] = ArrayBuffer.empty for { i <- 1 to N } f ++= factorize(i) f.sorted } var res: Long = 1 var i = 0 while(i < f.length) { var j = i while (j < f.length && f(i) == f(j)) j += 1 val len = j - i res = res * (len + 1) % MOD i = j } res } def main(args: Array[String]): Unit = { val sc = new Scanner(System.in) println(solve(sc.nextInt())) } def factorize(n: Int): Array[Int] = { // 見つからなかったら-1 def minFactor(n0: Int, i: Int): Int = { if (i > n0) -1 else if (n0 % i == 0) i else minFactor(n0, i + 1) } def step(n0: Int, acc: List[Int]): List[Int] = { minFactor(n0, 2) match { case -1 => acc case f => step(n0 / f, f :: acc) } } step(n, Nil).toArray } }
Submission Info
Submission Time | |
---|---|
Task | C - Factors of Factorial |
User | yakamoto |
Language | Scala (2.11.7) |
Score | 300 |
Code Size | 1071 Byte |
Status | AC |
Exec Time | 378 ms |
Memory | 25648 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 | 337 ms | 25404 KB |
sample_02.txt | AC | 338 ms | 25528 KB |
sample_03.txt | AC | 374 ms | 25488 KB |
subtask_1_certain_01.txt | AC | 338 ms | 25424 KB |
subtask_1_certain_02.txt | AC | 335 ms | 25412 KB |
subtask_1_certain_03.txt | AC | 378 ms | 25620 KB |
subtask_1_certain_04.txt | AC | 374 ms | 25648 KB |
subtask_1_rand_01.txt | AC | 356 ms | 25280 KB |
subtask_1_rand_02.txt | AC | 359 ms | 25516 KB |
subtask_1_rand_03.txt | AC | 356 ms | 25516 KB |