fork download
  1. import java.io.*;
  2. import java.util.*;
  3.  
  4. public class Main {
  5. static final int MAXN = 1_000_000;
  6. static final long MOD = 1_000_000_007L;
  7. static int[] spf = new int[MAXN + 1];
  8.  
  9. static void computeSPF() {
  10. for (int i = 2; i <= MAXN; i++) spf[i] = i;
  11. for (int i = 2; (long) i * i <= MAXN; i++) {
  12. if (spf[i] == i) {
  13. for (int j = i * i; j <= MAXN; j += i) {
  14. if (spf[j] == j) spf[j] = i;
  15. }
  16. }
  17. }
  18. }
  19.  
  20. static HashMap<Integer, Long> factorMap(long x) {
  21. HashMap<Integer, Long> map = new HashMap<>();
  22. while (x > 1) {
  23. int p = spf[(int) x];
  24. long cnt = 0;
  25. while (x % p == 0) {
  26. x /= p;
  27. cnt++;
  28. }
  29. map.put(p, map.getOrDefault(p, 0L) + cnt);
  30. }
  31. return map;
  32. }
  33.  
  34. public static void main(String[] args) throws Exception {
  35. FastScanner fs = new FastScanner(System.in);
  36. int n = fs.nextInt();
  37. int m = fs.nextInt();
  38. computeSPF();
  39.  
  40. HashMap<Integer, Long> base = new HashMap<>();
  41. for (int i = 2; i <= m; i++) {
  42. HashMap<Integer, Long> fm = factorMap(i);
  43. for (Map.Entry<Integer, Long> e : fm.entrySet()) {
  44. base.put(e.getKey(), base.getOrDefault(e.getKey(), 0L) + e.getValue());
  45. }
  46. }
  47.  
  48. StringBuilder out = new StringBuilder();
  49. for (int i = 1; i <= n; i++) {
  50. long val = fs.nextLong();
  51. HashMap<Integer, Long> merged = new HashMap<>(base);
  52. HashMap<Integer, Long> fm = factorMap(val);
  53. for (Map.Entry<Integer, Long> e : fm.entrySet()) {
  54. merged.put(e.getKey(), merged.getOrDefault(e.getKey(), 0L) + e.getValue());
  55. }
  56. long ans = 1L;
  57. for (long exp : merged.values()) {
  58. ans = (ans * ((exp + 1) % MOD)) % MOD;
  59. }
  60. out.append(ans).append(i == n ? "\n" : " ");
  61. }
  62. System.out.print(out.toString());
  63. }
  64.  
  65. static final class FastScanner {
  66. private final InputStream in;
  67. private final byte[] buffer = new byte[1 << 16];
  68. private int ptr = 0, len = 0;
  69. FastScanner(InputStream is) { in = is; }
  70. private int read() throws IOException {
  71. if (ptr >= len) {
  72. len = in.read(buffer);
  73. ptr = 0;
  74. if (len <= 0) return -1;
  75. }
  76. return buffer[ptr++];
  77. }
  78. long nextLong() throws IOException {
  79. int c; while ((c = read()) <= 32) if (c == -1) return Long.MIN_VALUE;
  80. int sign = 1;
  81. if (c == '-') { sign = -1; c = read(); }
  82. long val = 0;
  83. while (c > 32) { val = val * 10 + (c - '0'); c = read(); }
  84. return val * sign;
  85. }
  86. int nextInt() throws IOException { return (int) nextLong(); }
  87. }
  88. }
  89.  
Success #stdin #stdout 0.08s 57128KB
stdin
Standard input is empty
stdout
Standard output is empty