Loading...
Submission
Id When Author Problem Language CPU Memory Verdict
16706 2024-04-09 16:16:05 Sadman_sadi_anik_241 Binary Prime C 0 ms 1904 kb Wrong Answer - 4
Test Cases
CPU Memory Verdict
1 0 ms 1904 kb Accepted
2 0 ms 1788 kb Accepted
3 0 ms 1728 kb Accepted
4 0 ms 1800 kb Wrong Answer
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. else if(sum==2)
  30. {
  31. printf("Binary prime\n");
  32. }
  33. else if(sum==3)
  34. {
  35. printf("Binary prime\n");
  36. }
  37. else if(sum/2==0)
  38. {
  39. printf("-1\n");
  40. }
  41. else
  42. {
  43.  
  44. for (int k = 2; k <= sqrt(sum); k++)
  45. {
  46. if (sum % k == 0)
  47. {
  48. printf("-1\n");
  49. }
  50. else
  51. {
  52. printf("Binary prime\n");
  53. }
  54.  
  55.  
  56. }
  57. }
  58.  
  59. }
  60. }
  61.  
  62.  
  63.  
  64.  
  65.