Loading...
Submission
Id When Author Problem Language CPU Memory Verdict
16711 2024-04-09 16:57:43 Sadman_sadi_anik_241 Binary Prime C 0 ms 1904 kb Wrong Answer - 3
Test Cases
CPU Memory Verdict
1 0 ms 1904 kb Accepted
2 0 ms 1900 kb Accepted
3 0 ms 1840 kb Wrong Answer
4 - - Skipped
5 - - Skipped
6 - - Skipped
7 - - Skipped
8 - - Skipped
9 - - Skipped
10 - - Skipped
11 - - Skipped
Source Code
program.c
Download
  1. #include<stdio.h>
  2. #include<math.h>
  3. int main()
  4. {
  5. int A,i,j,B,l,sum;
  6. scanf("%d",&A);
  7. for(i=1; i<=A; i++)
  8. {
  9. scanf("%d",&B);
  10. sum=0;
  11. j=1;
  12. while(1)
  13. {
  14.  
  15.  
  16. l=B%2;
  17. sum=sum+l;
  18. B=B/2;
  19. l=0;
  20. if(B==0)
  21. break;
  22. j++;
  23. }
  24.  
  25. if (sum <= 1)
  26. {
  27. printf("-1\n ");
  28. }
  29.  
  30.  
  31.  
  32. else if(sum==2)
  33. {
  34. printf("Binary prime\n");
  35. }
  36. else if(sum==3)
  37. {
  38. printf("Binary prime\n");
  39.  
  40. }
  41.  
  42.  
  43. else
  44. {
  45. if(sum%2==0)
  46. {
  47. printf("-1\n");
  48. }
  49. else
  50.  
  51. {
  52. for (int k = 2; k <= sqrt(sum); k++)
  53. {
  54. if (sum % k == 0)
  55. {
  56. printf("-1\n");
  57. }
  58.  
  59.  
  60.  
  61.  
  62. }
  63. }
  64. }
  65.  
  66. }
  67. }
  68.  
  69.  
  70.  
  71.  
  72.