UVA – 10019 – Funny Encryption Method

import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);

		int T = in.nextInt();
		while (T-- != 0) {
			int N = in.nextInt();
			int b1 = Integer.toBinaryString(N).replaceAll("0", "").length();
			int xN =Integer.decode("0x" + N);
			int b2 = Integer.toBinaryString(xN).replaceAll("0", "").length();
			
			System.out.printf("%d %d\n", b1, b2);
		}
	}
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: