題目列表
簡單 時間限制:3 s記憶體限制:128 MB

Online Judge - 10019 - Funny Encryption Method

來源代碼:UVa
前往提交 ↓

A student from ITESM Campus Monterrey plays with a new encryption method for numbers. These method consist of the following steps:

Steps

Example

1. Read the number N to encrypt

M = 265

2. Interpret N as a decimal number

X_1 = 265\ (\text{decimal})

3. Convert the decimal interpretation of N to its binary representation

X_1 = 100001001\ (\text{binary})

4. Let b_1 be equal to the number of 1’s in this binary representation

b_1 = 3

5. Interpret N as a Hexadecimal number

X_2 = 265\ (\text{hexadecimal})

6. Convert the hexadecimal interpretation of N to its binary representation

X_2 = 1001100101

7. Let b_2 be equal to the number of 1’s in the last binary representation

b_2 = 5

8. The encryption is the result of M \operatorname{xor} (b_1 \times b_2)

265 \operatorname{xor} (3 \times 5) = 262

This student failed Computational Organization, thats why this student asked the judges of ITESM Campus Monterrey internal ACM programming Contest to ask for the numbers of 1’s bits of this two representations so that he can continue playing.

You have to write a program that read a Number and give as output the number b_1 and b_2

輸入說明

The first line will contain a number N which is the number of cases that you have to process. Each of the following N Lines

0 < N \le 1000

will contain the number M

0 < M \le 9999

(in decimal representation) which is the number the student wants to encrypt.

輸出說明

You will have to output N lines, each containing the number b_1 and b_2 in that order, separated by one space corresponding to that lines number to crypt

輸入輸出範例

範例 1

範例輸入
3
265
111
1234
範例輸出
3 5
6 3
5 5

範例 2

範例輸入
4
1
10
15
16
範例輸出
1 1
2 1
4 3
1 3

範例 3

範例輸入
4
100
255
9090
9999
範例輸出
3 1
8 5
5 4
8 8

討論

登入後即可加入討論。 登入

目前還沒有討論文章。

最近提交

目前還沒有提交紀錄。

登入後即可撰寫程式、測試範例及提交解答。

登入