Submission
Id | When | Author | Problem | Language | CPU | Memory | Verdict |
---|---|---|---|---|---|---|---|
16863 | 2024-04-19 15:22:28 | dnt | Binary Prime | Java | 113 ms | 42452 kb | Runtime Error - 9 |
Test Cases
CPU | Memory | Verdict | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
1 | 101 ms | 38176 kb | Accepted | ||||||||
2 | 106 ms | 38800 kb | Accepted | ||||||||
3 | 103 ms | 38312 kb | Accepted | ||||||||
4 | 104 ms | 38860 kb | Accepted | ||||||||
5 | 102 ms | 42452 kb | Accepted | ||||||||
6 | 104 ms | 38340 kb | Accepted | ||||||||
7 | 104 ms | 38660 kb | Accepted | ||||||||
8 | 105 ms | 41888 kb | Accepted | ||||||||
9 | 113 ms | 42300 kb | Runtime Error | ||||||||
10 | - | - | Skipped | ||||||||
11 | - | - | Skipped | ||||||||
Source Code
program.java
import java.util.Scanner; public class Main { // Function to count the number of set bits in a binary representation static int countSetBits(int n) { int count = 0; while (n > 0) { count += n & 1; n >>= 1; } return count; } // Function to check if a number is prime static boolean isPrime(int n) { if (n <= 1) return false; for (int i = 2; i * i <= n; i++) { if (n % i == 0) return false; } return true; } // Read the number of queries int T = sc.nextInt(); for (int t = 0; t < T; t++) { // Read the decimal number int N = sc.nextInt(); // Convert decimal number to binary and count set bits int setBits = countSetBits(N); // Check if the sum of set bits is prime if (isPrime(setBits)) { } else { } } } }