Count the array
Practice
3.4 (8 votes)
Basic programming
Recursion
Recursion and backtracking
C++
Problem
72% Success 2235 Attempts 30 Points 1s Time Limit 256MB Memory 1024 KB Max Code

You are given an integer \(P\).

Also, you are given \(Q\) queries of the following type:

  • \(N\): Determine the count of distinct arrays of size \(\le N\) and \(\ge 1\) such that:
    • Each array element is a prime number
    • Product of the value of all the array elements is \(\le P\)
    • Array formed is palindromic

Note

  • Two arrays are said to be distinct if there exists at least one index where the value of element present in both the arrays is different.
  • An array is said to be palindromic if it reads same from the left to right and right to left direction.
  • Since the count can be very large, print the output in modulo \(10^9 + 7\).
  • Assume \(1\) based indexing.

Input format

  • The first line contains an integer \(P\).
  • The second line contains an integer \(Q\).
  • The next line contains \(Q\) space-separated integers that denotes the value of \(N\) for each query.

Output format

Print \(Q\) space-separated integers denoting the result for \(Q\) queries.

Constraints

\(1 \le N \le 10^9 \\ 1 \le P \le 10^6 \\ 1 \le Q \le 10^5\)

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:30
10 votes
Tags:
BacktrackingBasic ProgrammingRecursion
Points:30
93 votes
Tags:
BacktrackingBasic ProgrammingNumber theoryRecursion
Editorial

Login to unlock the editorial