Loading...
Submission
Id When Author Problem Language CPU Memory Verdict
16714 2024-04-09 17:07:29 Sadman_sadi_anik_241 Binary Prime C 0 ms 0 kb Compilation Error
Test Cases
CPU Memory Verdict
1 0 ms 0 kb Compilation Error
2 - - Skipped
3 - - Skipped
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. for (int k = 2; k <= sqrt(sum); k++)
  33. {
  34. if (sum % k == 0)
  35. {
  36. printf("-1\n");
  37. }
  38.  
  39. else
  40. {
  41. printf("Binary prime\n");
  42. }
  43.  
  44.  
  45. }
  46. else if(sum==2)
  47. {
  48. printf("Binary prime\n");
  49. }
  50. else if(sum==3)
  51. {
  52. printf("Binary prime\n");
  53.  
  54. }
  55. else if (sum % 2 == 0)
  56. {
  57. printf("-1\n");
  58. }
  59.  
  60.  
  61. }
  62.  
  63.  
  64. }
  65.  
  66.  
  67.  
  68.  
  69.