Special numbers

2.5

2 votes
Primality test, Number theory, Basic Programming, Easy, Mathematics, Sieve
Problem

A special number is defined as a number which has at least P distinct prime factors.

Write a program to determine whether a number N is a special number.

Input format

  • First line: P
  • Second line: T (number of test cases)
  • Next T lines: N

Output format

For each test case, print YES or NO depending on the result.

Constraints

1T20

1N107
1PN

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

Here P=2,

1 has 0 prime factors

6 has 2 prime factors- 2,3

7 has 1 - 7

8 has 1 - 2

9 has 1 - 3

10 has 2 - 2,5

Editor Image

?