Submission #2209685
Source Code Expand
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.InputMismatchException; import java.util.List; import java.util.Map; import java.util.StringTokenizer; import java.util.TreeMap; public class Main { public static void main(String[] args) throws IOException { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); PrintWriter out = new PrintWriter(outputStream); TaskX solver = new TaskX(); solver.solve(1, in, out); out.close(); } static int mod = 1000000007; static class TaskX { public void solve(int testNumber, InputReader in, PrintWriter out) { int n = in.nextInt(); Integer[] primes = MathUtils.getPrimes(n); int[] count = new int[primes.length]; for (int i = 1; i <= n; i++) { int t = i; for (int j = 0; j < primes.length; j++) { while (t % primes[j] == 0) { count[j]++; t = t / primes[j]; } } } long ans = 1; for (int i = 0; i < count.length; i++) { ans = (ans*(count[i]+1)%mod); } out.println(ans); } } static class MathUtils { public static Integer[] getPrimes (int n) { boolean[] isPrime = new boolean[n+1]; Arrays.fill(isPrime, true); isPrime[0] = isPrime[1] = false; for (int i = 2; i < isPrime.length; i++) { if (!isPrime[i]) continue; for (int j = i + i; j < isPrime.length; j += i) { isPrime[j] = false; } } List<Integer> list = new ArrayList<>(); for (int i = 1; i < isPrime.length; i++) { if (isPrime[i]) { list.add(i); } } return list.toArray(new Integer[list.size()]); } } static class ArrayUtils { public static Map<Integer, Integer> getCountMap(int[] array) { Map<Integer, Integer> map = new TreeMap<>(); for (int x : array) map.merge(x, 1, Integer::sum); return map; } } static class InputReader { BufferedReader in; StringTokenizer tok; public String nextString() { while (!tok.hasMoreTokens()) { try { tok = new StringTokenizer(in.readLine(), " "); } catch (IOException e) { throw new InputMismatchException(); } } return tok.nextToken(); } public int nextInt() { return Integer.parseInt(nextString()); } public long nextLong() { return Long.parseLong(nextString()); } public int[] nextIntArray(int n) { int[] res = new int[n]; for (int i = 0; i < n; i++) { res[i] = nextInt(); } return res; } public long[] nextLongArray(int n) { long[] res = new long[n]; for (int i = 0; i < n; i++) { res[i] = nextLong(); } return res; } public InputReader(InputStream inputStream) { in = new BufferedReader(new InputStreamReader(inputStream)); tok = new StringTokenizer(""); } } }
Submission Info
Submission Time | |
---|---|
Task | C - Factors of Factorial |
User | tutuz |
Language | Java8 (OpenJDK 1.8.0) |
Score | 300 |
Code Size | 3177 Byte |
Status | AC |
Exec Time | 87 ms |
Memory | 22612 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 | 71 ms | 19028 KB |
sample_02.txt | AC | 70 ms | 19028 KB |
sample_03.txt | AC | 87 ms | 20820 KB |
subtask_1_certain_01.txt | AC | 72 ms | 22612 KB |
subtask_1_certain_02.txt | AC | 72 ms | 21076 KB |
subtask_1_certain_03.txt | AC | 87 ms | 21332 KB |
subtask_1_certain_04.txt | AC | 85 ms | 19540 KB |
subtask_1_rand_01.txt | AC | 73 ms | 18388 KB |
subtask_1_rand_02.txt | AC | 72 ms | 17876 KB |
subtask_1_rand_03.txt | AC | 73 ms | 21076 KB |