#P8842. [传智杯 #4 初赛] 小卡与质数 2

    ID: 9093 远端评测题 1000ms 128MiB 尝试: 0 已通过: 0 难度: 6 上传者: 标签>素数判断,质数,筛法位运算传智杯

[传智杯 #4 初赛] 小卡与质数 2

Background

Xiaoka has become obsessed with prime numbers!

Problem Description

Xiaoka has recently become obsessed with prime numbers, so he wants to turn any number into a prime number!

Xiaoka has TT queries. Each time, you are given a number xx. You need to ask: how many non-negative integers yy less than xx make xyx \oplus y a prime number, where \oplus denotes bitwise XOR.

Input Format

The first line contains a positive integer TT (1T105)(1 \le T \le 10^5), meaning there are TT queries.

The next TT lines each contain a positive integer xx (1x106)(1 \le x \le 10^6).

Output Format

For each query, output one line with one integer, representing the answer.

9
5
6
7
8
9
10
100
1000
10000
2
4
4
2
2
4
22
163
1132

Hint

Translated by ChatGPT 5