Geeksforgeeks

Error

×

Leaderboard

Showing:

Handle | Score |
---|---|

@Ibrahim Nash | 6420 |

@blackshadows | 6376 |

@mb1973 | 5604 |

@Quandray | 5231 |

@akhayrutdinov | 5111 |

@saiujwal13083 | 4510 |

@sanjay05 | 3762 |

@kirtidee18 | 3673 |

@marius_valentin_dragoi | 3522 |

@sushant_a | 3459 |

@verma_ji | 3413 |

Complete Leaderboard | |

Handle | Score |

@codersgroup18 | 799 |

@sriramgoparaju99 | 737 |

@Manikanta punnam | 629 |

@rdakka | 606 |

@prankursharma31 | 597 |

@praveenbgp6 | 546 |

@sanskar94511 | 531 |

@purohitmn02 | 529 |

@yashkaril4 | 517 |

@abhikarshgupta | 474 |

@rohitgarg2825 | 464 |

Complete Leaderboard |

You have given a list of q queries and for every query, you are given an integer N. The task is to find how many numbers** less than or equal to N **have numbers of divisors exactly equal to **3**.

**Example 1:**

**Input:
**q = 1
query[0] = 6
**Output:**
1
**Explanation:**
There is only one number 4 which has
exactly three divisors 1, 2 and 4 and
less than equal to 6.

**Example 2:**

**Input:
**q = 2
query[0] = 6
query[1] = 10
**Output:
**1
2
**Explanation:
**For query 1 it is covered in the
example 1.
query 2: There are two numbers 4 and 9
having exactly 3 divisors and less than
equal to 10.

**Your Task: **

You don't need to read input or print anything. Your task is to complete the function **threeDivisors()** which takes an integer **q** and a list of integer of size **q** as input parameter and returns the list containing the count of the numbers having exactly 3 divisors for each query.

**Expected Time Complexity:** O(NlogN),

**Expected Auxiliary Space:** O(N), where N is min(10^6,N)

**Constraints :**

1 <= q <= 10^{3}

1 <= query[i] <= 10^{12}

Login to report an issue on this page.

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes
3 Divisors

...