electicode
АсосӣКурсҳоМанбаъҳоМасъалаҳоОлимпиадаи миллӣМусобиқаҳоҶадвали роҳбарон
...

Beautiful Numbers

Маҳдудияти вақт: 1000msМаҳдудияти ҳофиза: 256MB
Ҳамаи ҳалҳо

Тавсифи масъала

A number is called beautiful if it can be represented in the form pqp^qpq, where ppp and qqq are prime numbers. For example, 4=224 = 2^24=22 is beautiful, 343=73343 = 7^3343=73 is beautiful, but 101010 and 424242 are not beautiful.

You are given QQQ queries. In each query, you are given a number NNN. Your task is to find how many beautiful numbers exist in the range [1…N][1 \ldots N][1…N].

Input Format

The first line contains a single integer QQQ (1≤Q≤105)(1 \leq Q \leq 10^5)(1≤Q≤105).

The second line contains QQQ integers --- the value NNN (1≤N≤109)(1 \leq N \leq 10^9)(1≤N≤109) for each query.

Output Format

For each of the QQQ queries, print the answer separated by spaces.

Scoring

SubtaskConstraintPoints
111Q≤100Q \leq 100Q≤100, N≤1000N \leq 1000N≤1000222

Notes

In the first sample, for N=3N=3N=3: there are 000 beautiful numbers in [1,3][1,3][1,3]; for N=7N=7N=7: there is 111 beautiful number (44); for : there are beautiful numbers (, , ).

In the second sample, for N=40N=40N=40: there are 666 beautiful numbers.

Мисолҳо

Мисол 1
Вуруд
3
3 7 10
Баромад
0 1 3
Мисол 2
Вуруд
1
40
Баромад
6

© 2026 Electicode. All rights reserved.

222
N≤1000N \leq 1000N≤1000
333
333No additional constraints555
4
N=10N=10N=10
333
444
888
999