UVa 10519

From Algorithmist
Jump to navigation Jump to search

10519 - !! Really Strange !![edit]

Summary[edit]

This is a simple problem of multiplication and addition of big integers.

Explanation[edit]

Work out the solutions of some very small cases like when n is 1, 2, 3 etc. using pen and paper. You will see they form a simple series. Now formulate an expression that evaluates to the result given the value of n, which is really easy. You can use java BigInteger, or any big integer class of your own to solve this problem.

Gotchas[edit]

The case when n = 0. Observe the picture given in the problem description and use zero circles there. How many region(s) are there now?

Notes[edit]

Keep the case of zero circles in mind and you will have no problems!

Implementations[edit]

You may use java BigInteger, or any big integer class of your own. No memorization is required, and is not possible either. Just use the formula to evaluate each answer.

Input[edit]

1
2
3
4
5

Output[edit]

2
4
8
14
22

References[edit]

Java BigInteger help: http://docs.oracle.com/javase/7/docs/api/java/math/BigInteger.html