This page is still under construction.

Parts of this page are still being built. What you see may change.

Numbers (Small)

Time limit5sMemory limit512 MB

Summary
Given small n up to 30, print the last three digits of the integer part of (3 + sqrt(5))^n, formatted as Case #X: Y.
Level

Medium4 of 10

Topics
Math, Number theory, Implementation
Solved
No attempts yet

Problem

For a positive integer nn, find the last three digits before the decimal point of (3+5)n(3+\sqrt{5})^n.

For example, if n=5n = 5 then (3+5)5=3935.73982…(3+\sqrt{5})^5 = 3935.73982\ldots, so the answer is 935. If n=2n = 2 then (3+5)2=27.4164079…(3+\sqrt{5})^2 = 27.4164079\ldots, so the answer is 027.

Input

The first line contains the number of test cases TT. Each of the next TT lines contains one positive integer nn.

Limits

  • 1≤T≤1001 \le T \le 100
  • 2≤n≤302 \le n \le 30

Output

For each test case, print one line in the following format.

Case #X: Y

Here XX is the number of the test case and YY is the last three digits of the integer part of (3+5)n(3+\sqrt{5})^n. If the integer part has fewer than three digits, pad it with leading zeros so that the output has exactly three digits.

Examples4

  1. Example 1

    Input
    2
    5
    2
    
    Expected output
    Case #1: 935
    Case #2: 027
    
  2. Example 2

    Input
    5
    10
    13
    17
    2
    30
    
    Expected output
    Case #1: 047
    Case #2: 055
    Case #3: 095
    Case #4: 027
    Case #5: 647
    
  3. Example 3

    Input
    4
    5
    5
    5
    5
    
    Expected output
    Case #1: 935
    Case #2: 935
    Case #3: 935
    Case #4: 935
    
  4. Example 4

    Input
    2
    3
    4
    
    Expected output
    Case #1: 143
    Case #2: 751