Integer to Excel

View as PDF

Submit solution


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

Author:
Problem type
Allowed languages
Python

Problem Statement

Given an integer columnNumber, return its corresponding column title as it appears in an Excel sheet.

For example:

    A -> 1
    B -> 2
    C -> 3
    ...    
    Z -> 26
    AA -> 27
    AB -> 28 
    ...

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 contains a natural number N.

Limits

Memory limits: 32MB.

Time limits: 1 second.

1 \leq T \leq 100

1 \leq N \leq 10^9

Test Set 1

Sample Case

Test Set 2

1 \leq N \leq 1000

Test Set 3

1 \leq N \leq 10^6

Test Set 4

1 \leq N \leq 10^9

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 column title in an Excel sheet.

Sample Input

3
1
26
28

Sample Output

Case #1: A
Case #2: Z
Case #3: AB

Ref

https://leetcode.com/problems/excel-sheet-column-title/

Hint

chr ord mod operator


Comments

There are no comments at the moment.