Loading...
Submission
Id When Author Problem Language CPU Memory Verdict
16969 2024-04-23 17:05:51 ewu_intra24_mock_u_187 Binary Prime C++ 17 1 ms 3408 kb Accepted
Test Cases
CPU Memory Verdict
1 1 ms 3340 kb Accepted
2 1 ms 3340 kb Accepted
3 1 ms 3360 kb Accepted
4 1 ms 3364 kb Accepted
5 1 ms 3328 kb Accepted
6 1 ms 3352 kb Accepted
7 1 ms 3368 kb Accepted
8 1 ms 3408 kb Accepted
9 1 ms 3384 kb Accepted
10 1 ms 3372 kb Accepted
11 1 ms 3376 kb Accepted
Source Code
program.cpp
Download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
  4. #define all(a) (a).begin(),(a).end()
  5. #define nl cout<<'\n' ;
  6. #define dbg(x) cerr<<"Line no- "<<__LINE__<<": "<<#x<<" = "<<x<<'\n';
  7. #define out(a) cout<<a<<'\n';
  8. #define hmm(ok) cout<<(ok==1?"YES":"NO")<<'\n';
  9. #define ld long double
  10. #define ll long long
  11. #define ull unsigned long long
  12. const ld PI = 3.141592653589793238462;
  13. const ll MOD = 1e9+7;
  14. const ll INF = 1e18;
  15.  
  16. bool is_prime(int n)
  17. {
  18. for(int i=2; i*i<=n; i++)
  19. {
  20. if(n%i==0)
  21. {
  22. return false;
  23. }
  24. }
  25. return true;
  26. }
  27.  
  28. void solve()
  29. {
  30. ll n;
  31. cin>>n;
  32. int cnt=0;
  33. while(n>0)
  34. {
  35. cnt+=n%2;
  36. n/=2;
  37. }
  38. if(is_prime(cnt) and cnt!=1){
  39. out("Binary prime")
  40. }
  41. else{
  42. out(-1)
  43. }
  44. }
  45.  
  46. int main()
  47. {
  48. faster;
  49. int test;
  50. cin>>test;
  51. int i=1;
  52. while(test--){
  53. solve();
  54. //cout<<"Case "<<i++<<":";
  55. }
  56. }
  57.