This problem was proposed to my friend Alyona in the course of job interview, though not for programmer but rather for QA (aka "software tester") at some local company.
Let it be shared here, as I found it allows not only "simple and straightforward" solution - though I'm not sure I would be glad to meet the "cryptic advanced" solution in enterprise production code, ha-ha.
Construction company just have built skyscraper of immense height, but with only single appartment on each floor.
Appartment cost is X
at the lowest floors, but is incremented by 1000
every M
floors. The goal is to
calculate how much profit the company gets by selling the whole building of N
storeys.
To clarify: if N = 30
and price starts with X = 10000
, incrementing every M = 10
floors, then first ten
apartments (at floors 0 .. 9
, where 0
means "ground floor") are sold for 10000
each, next ten
(at floors 10 .. 19
) go for 11000
, and ten last for 12000
.
Input gives the number T
of testcases in the first line.
Then T
lines follow, each with three values N M X
.
Answer should give building total prices for every testcase, space-separated. Prices are integers, no cents, pennies or kopeeks please :)
Example
input:
3
1 1 1000
3 2 1000
30 10 10000
answer:
1000 4000 330000