630D.md (1644B)
1 Source: https://codeforces.com/problemset/problem/630/D 2 3 D. Hexagons! 4 5 time limit per test 6 7 0.5 seconds 8 9 memory limit per test 10 11 64 megabytes 12 13 input 14 15 standard input 16 17 output 18 19 standard output 20 21 After a probationary period in the game development company of IT City Petya was included in a group of the programmers that develops a new turn-based strategy game resembling the well known "Heroes of Might & Magic". A part of the game is turn-based fights of big squadrons of enemies on infinite fields where every cell is in form of a hexagon. 22 23 Some of magic effects are able to affect several field cells at once, cells that are situated not farther than *n* cells away from the cell in which the effect was applied. The distance between cells is the minimum number of cell border crosses on a path from one cell to another. 24 25 It is easy to see that the number of cells affected by a magic effect grows rapidly when *n* increases, so it can adversely affect the game performance. That's why Petya decided to write a program that can, given *n*, determine the number of cells that should be repainted after effect application, so that game designers can balance scale of the effects and the game performance. Help him to do it. Find the number of hexagons situated not farther than *n* cells away from a given cell. 26 27  28 29 Input 30 31 The only line of the input contains one integer *n* (0 ≤ *n* ≤ 109). 32 33 Output 34 35 Output one integer — the number of hexagons situated not farther than *n* cells away from a given cell. 36 37 Examples 38 39 Input 40 41 ``` 42 2 43 ``` 44 45 Output 46 47 ``` 48 19 49 ```