알고리즘(CF)2017. 6. 7. 21:42

Below we will define an n-interesting polygon. Your task is to find the area of a polygon for a given n.

1-interesting polygon is just a square with a side of length 1. An n-interesting polygon is obtained by taking the n - 1-interesting polygon and appending 1-interesting polygons to its rim, side by side. You can see the 1-, 2-, 3- and 4-interesting polygons in the picture below.



Example


  • For n = 2, the output should be
    shapeArea(n) = 5;
  • For n = 3, the output should be
    shapeArea(n) = 13.



Code


int shapeArea(int n) {
2

 

3
}


'알고리즘(CF)' 카테고리의 다른 글

7. almostIncreasingSequence  (1) 2017.06.07
6. make Array Consecutive2  (1) 2017.06.07
4. adjacentElementsProduct  (1) 2017.06.07
3. checkPalindrome  (1) 2017.06.07
2. centuryFromYear  (1) 2017.06.07
Posted by EL2A