Connected Components
Algorithms
Graphs
Graph representation
56.0% success
964 attempts
5s time
256MB memory
1024KB max code

You are given an undirected simple graph \(G\) containing exactly \(n\) distinct nodes.

The nodes are numbered from \(1\) to \(n\).

Suppose that \((u,v)\) is an edge of \(G\) if and only if \(u \cdot v\) is a perfect square.

Please compute the number of the connected components of \(G\).

Input Format

  • The first line contains a single integer \(T\) — the number of test cases.
  • Each test case consists one positive integer \(n\) — the number of distinct nodes.

Output Format

  • For each testcase, output the number of the connected components of \(G\).

Constraints

  • \(1 \leq T \leq 10^4\)
  • \(1 \leq n \leq 2 \cdot 10^5\)
  • The sum of \(n\) over all test cases does not exceed \(10^7\).
Examples
Input
4
1
2
3
4
Output
1
2
3
3
Explanation

For the \(4\)th case, since \(1 \cdot 4 = 4 = 2^2\), the node \(4\) is connected to node \(1\).

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 Editor...