Loading...
Submission
Id When Author Problem Language CPU Memory Verdict
16910 2024-04-23 00:27:03 zunayed Binary Prime C++ 17 46 ms 3592 kb Wrong Answer - 9
Test Cases
CPU Memory Verdict
1 45 ms 3396 kb Accepted
2 45 ms 3592 kb Accepted
3 45 ms 3448 kb Accepted
4 45 ms 3516 kb Accepted
5 45 ms 3440 kb Accepted
6 45 ms 3536 kb Accepted
7 45 ms 3516 kb Accepted
8 45 ms 3444 kb Accepted
9 46 ms 3352 kb Wrong Answer
10 - - Skipped
11 - - Skipped
Source Code
program.cpp
Download
  1. /* ...Bismillahir Rahmanir Raheem... */
  2.  
  3. /*
  4. Problem: binary_prime
  5. Date: 2024-Apr-23
  6. */
  7. #include<bits/stdc++.h>
  8. using namespace std;
  9. #define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
  10. #define all(a) (a).begin(),(a).end()
  11. #define nl cout<<'\n' ;
  12. #define out(a) cout<<a<<'\n';
  13. #define hmm(ok) cout<<(ok==1?"YES":"NO")<<'\n';
  14. #define ld long double
  15. #define ll long long
  16. #define ull unsigned long long
  17. const ld PI = 3.141592653589793238462;
  18. const ll MOD = 1e9+7;
  19. const ll INF = 1e18;
  20. const int N=1e6;
  21. vector<bool>prime(N+1,true);
  22.  
  23.  
  24. void sieve() {
  25. for (int p = 2; p * p <= N; p++) {
  26. if (prime[p]) {
  27. for (int i = p * p; i <= N; i += p)
  28. prime[i] = false;
  29. }
  30. }
  31. }
  32.  
  33. void solve()
  34. {
  35. int n;
  36. cin>>n;
  37. bitset<64>keep(n);
  38. int cnt=0;
  39. for(int i=0; i<64; i++)
  40. {
  41. if(keep.test(i))
  42. {
  43. cnt++;
  44. }
  45. }
  46. if(prime[cnt] and cnt!=1)
  47. {
  48. out("Binary prime");
  49. }
  50. else{
  51. out(-1)
  52. }
  53. }
  54.  
  55.  
  56. int main()
  57. {
  58. faster;
  59. sieve();
  60. int test;
  61. cin>>test;
  62. int i=1;
  63. while(test--){
  64. solve();
  65. //cout<<"Case "<<i++<<":";
  66. }
  67. }