Rotate the Integer

View as PDF

Submit solution


Points: 20 (partial)
Time limit: 1.0s
Memory limit: 32M

Authors:
Problem type
Allowed languages
Python

Problem Statement

Given a non-negative integer N, calculate the result of rotating N to the left by one bit. Assume N fits in 8 bits.

Input Specification

The first line of the input gives the number of test cases, T, T test cases follow. Each test case consists of a line. The line contain a non-negative integer N.

Limits

Memory limits: 32MB.

Time limits: 1 second.

1 \leq T \leq 1000

0 \leq N \leq 255

Test Set 1

Sample Case.

Test Set 2

1 \leq N \leq 15

Test Set 3

0 \leq N \leq 63

Test Set 4

0 \leq N \leq 255

Output Specification

For each test case, output one line containing Case #x: y, where x is the case number(starting from 1) and y is the result of rotating N to the left by one bit.

Sample Input

3
12
130
255

Sample Output

Case #1: 24
Case #2: 5
Case #3: 255

Explaination

In Sample Case #1, the binary representation of 12 is 0b1100 and binary representation of 24 is 0b11000.

In Sample Case #2, the binary representation of 130 is 0b10000010 and binary representation of 5 is 0b101.

In Sample Case #3, the binary representation of 255 is 0b11111111.

Hint

bitwise and/or operator,shift oprator,bin


Comments


  • 0
    JMEOW  commented on Oct. 9, 2023, 9:55 p.m. edited

    :)