|
Problem 1:
Given a positive integer n, find the odd integer o and the integer p such that n = o*2 to the power p.
Example : For n = 24, o = 3 and p = 3.
Task: Write a program that:
1. Reads a positive integer n from the standard input,
2. Computes the odd integer o and the integer p such that n = o*2 to the power p.
3. Writes the result to the standard output.
Input:
The first and only line of the input contains exactly one integer n, 1 <= n <= 10 to the power 6.
Output:
The output should contain two integers o and p separated by a single space such that n = o*2 to the power p.
Example:
For the input:
24
the correct answer is:
3 3
Problem 2:
Given a positive integer n, find the positions of all 1's in its binary representation. The position of the least significant bit is 0.
Example : For n = 24, o = 3 and p = 3.
Task: Write a program that:
1. Reads a positive integer n from the standard input,
2. Computes the positions of 1's in the binary representation of n.
3. Writes the result to the standard output.
Input:
The first and only line of the input contains exactly one integer n, 1 <= n <= 10 to the power 6.
Output:
The output should contain increasing sequence of integers separated by single spaces with the positions of 1's in the binary representation of the input number.
Example:
For the input:
13
the correct answer is:
0 2 3
Problem 3:
Check whether a given character upper case lower case or special case without using logical operators.
|