06 Feb shape Area
Posted at 23:47h in Coding 0 Comments
Below we will define an
n-interesting polygon. Your task is to find the area of a polygon for a given
1-interesting polygon is just a square with a side of length
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
4-interesting polygons in the picture below.
n = 2, the output should be
solution(n) = 5;
n = 3, the output should be
solution(n) = 13.
- [execution time limit] 4 seconds (py3)
- [input] integer nGuaranteed constraints:
1 ≤ n < 104.
- [output] integerThe area of the
if n == 1:
return solution(n – 1) + 4 * (n – 1)