This page is still under construction.

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

Disposable Cup

Time limit1sMemory limit32 MB

Summary
Given A, B, and N, find every total height achievable by stacking N cups, where same-facing neighbors add A and opposite-facing ones add A+B.
Level

Medium4 of 10

Topics
Combinatorics, Math
Solved
No attempts yet

Problem

Chanwoo stacks NN paper cups into one tower. He thinks a triangle is too hard to build, so the tower runs straight up and down. A single cup has the shape below.

One cup is A+BA + B tall. When a cup is nested onto a cup that faces the same way, the upper cup sinks BB into the lower one, so the tower grows by only AA. Two neighbouring cups that face opposite ways meet rim to rim or base to base and do not nest, so the two parts simply add their heights.

Six cups stacked in the pattern )(())) look like this.

With A=8A = 8 and B=36B = 36, that tower is 156mm tall.

Chanwoo can choose the direction of every cup. Write a program that finds every tower height Chanwoo can build with NN cups.

Input

The first line contains AA, BB, and NN separated by spaces. (1≤A,B,N≤1 0001 \le A, B, N \le 1\,000, 2A≤B2A \le B)

Output

Print every achievable tower height in ascending order on one line, separated by spaces.

Examples3

  1. Example 1

    Input
    8 36 6
    
    Expected output
    84 120 156 192 228 264
    
  2. Example 2

    Input
    1 2 1
    
    Expected output
    3
    
  3. Example 3

    Input
    1 2 2
    
    Expected output
    4 6