Submission
Id | When | Author | Problem | Language | CPU | Memory | Verdict |
---|---|---|---|---|---|---|---|
16912 | 2024-04-23 00:33:56 | zunayed | Binary Prime | C++ 17 | 45 ms | 3596 kb | Accepted |
Test Cases
CPU | Memory | Verdict | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
1 | 45 ms | 3464 kb | Accepted | ||||||||
2 | 45 ms | 3520 kb | Accepted | ||||||||
3 | 45 ms | 3400 kb | Accepted | ||||||||
4 | 45 ms | 3392 kb | Accepted | ||||||||
5 | 45 ms | 3596 kb | Accepted | ||||||||
6 | 45 ms | 3580 kb | Accepted | ||||||||
7 | 45 ms | 3516 kb | Accepted | ||||||||
8 | 45 ms | 3552 kb | Accepted | ||||||||
9 | 45 ms | 3476 kb | Accepted | ||||||||
10 | 45 ms | 3444 kb | Accepted | ||||||||
11 | 45 ms | 3548 kb | Accepted | ||||||||
Source Code
program.cpp
/* ...Bismillahir Rahmanir Raheem... */ /* Problem: binary_prime Date: 2024-Apr-23 */ #include<bits/stdc++.h> using namespace std; #define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); #define all(a) (a).begin(),(a).end() #define nl cout<<'\n' ; #define out(a) cout<<a<<'\n'; #define hmm(ok) cout<<(ok==1?"YES":"NO")<<'\n'; #define ld long double #define ll long long #define ull unsigned long long const ld PI = 3.141592653589793238462; const ll MOD = 1e9+7; const ll INF = 1e18; const int N=1e6; vector<bool>prime(N+1,true); void sieve() { for (ll p = 2; p * p <= N; p++) { if (prime[p]) { for (ll i = p * p; i <= N; i += p) prime[i] = false; } } } void solve() { ll n; cin>>n; bitset<64>keep(n); int cnt=0; for(int i=0;n>0;i++){ cnt += n%2; n = n/2; } if(prime[cnt] and cnt!=1) { out("Binary prime"); } else{ out(-1) } } int main() { faster; sieve(); int test; cin>>test; int i=1; while(test--){ solve(); //cout<<"Case "<<i++<<":"; } }