-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCPP0140.cpp
More file actions
39 lines (35 loc) · 752 Bytes
/
CPP0140.cpp
File metadata and controls
39 lines (35 loc) · 752 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <bits/stdc++.h>
#define MOD 1000000007
#define MAX 10000001
#define ll long long
using namespace std;
int prime(int n) {
for (int i = 2; i <= sqrt(n); i++) {
if (n % i == 0)
return 0;
}
return n > 1;
}
int sohoanhao(ll n) {
for (int i = 2; i <= 32; i++) {
if (prime(i)) {
ll temp = pow(2, i) - 1;
if (prime(temp)) {
ll shh = 1ll * pow(2, i - 1) * (pow(2, i) - 1);
if (n == shh)
return 1;
}
}
}
return 0;
}
int main() {
int t;
cin >> t;
while (t--) {
ll n;
cin >> n;
cout << sohoanhao(n) << endl;
}
return 0;
}