Loading...
Submission
Id When Author Problem Language CPU Memory Verdict
16715 2024-04-09 17:22:55 Sadman_sadi_anik_241 Binary Prime C 0 ms 1908 kb Wrong Answer - 10
Test Cases
CPU Memory Verdict
1 0 ms 1788 kb Accepted
2 0 ms 1832 kb Accepted
3 0 ms 1908 kb Accepted
4 0 ms 1816 kb Accepted
5 0 ms 1736 kb Accepted
6 0 ms 1840 kb Accepted
7 0 ms 1900 kb Accepted
8 0 ms 1788 kb Accepted
9 0 ms 1792 kb Accepted
10 0 ms 1788 kb Wrong Answer
11 - - Skipped
Source Code
program.c
Download
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. int main() {
  5. int A, i, j, B, l, sum;
  6. scanf("%d", &A);
  7. for (i = 1; i <= A; i++) {
  8. scanf("%d", &B);
  9. sum = 0;
  10. j = 1;
  11. while (1) {
  12. l = B % 2;
  13. sum = sum + l;
  14. B = B / 2;
  15. l = 0;
  16. if (B == 0)
  17. break;
  18. j++;
  19. }
  20.  
  21. if (sum <= 1) {
  22. printf("-1\n");
  23. } else if (sum == 2 || sum == 3) {
  24. printf("Binary prime\n");
  25. } else if (sum % 2 == 0) {
  26. printf("-1\n");
  27. } else {
  28. int isPrime = 1;
  29. for (int k = 2; k <= sqrt(sum); k++) {
  30. if (sum % k == 0) {
  31. isPrime = 0;
  32. break;
  33. }
  34. }
  35. if (isPrime) {
  36. printf("Binary prime\n");
  37. } else {
  38. printf("-1\n");
  39. }
  40. }
  41. }
  42. return 0;
  43. }
  44.