Description
After a probationary period in the game development Company's IT City Petya is included in a group of the programmers th At develops a new turn-based strategy game resembling the well known "Heroes of Might & Magic". A part of the game was turn-based fights of big squadrons of enemies on infinite fields where every cell was in form of a He Xagon.
Some of magic Effects is able to affect several field cells at once, cells, is situated not farther than n cells away from the cell in which, the effect was applied. The distance between cells are the minimum number of cell border crosses on a path from one cell to another.
It's easy-to-see-the number of cells affected by a magic effect grows rapidly when n increases, so it C An adversely affect the game performance. That's why Petya decided to write a program so can, given n, determine the number of cells that should be r Epainted 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.
Input
The only line of the input contains one integer n (0≤ n ≤109).
Output
Output one integer-the number of hexagons situated not farther than n cells away from a given cell.
Examples
input
2
Output
19
Number of numbers, asking how many are around to 0.
#include <stdio.h>//#include <bits/stdc++.h> #include <string.h> #include <iostream> #include <math.h> #include <sstream> #include <set> #include <queue> #include <map> #include < vector> #include <algorithm> #include <limits.h> #define INF 0x7fffffff#define inf 0x7fffffffffffffff# Define Lson l,m,rt<<1#define Rson m+1,r,rt<<1|1#define LL long long#define ULL unsigned long longusing Namespa CE std; ll Powl (ll X, ll N) { ll pw = 1; while (n > 0) { if (N & 1) //N & 1 equivalent to (n% 2) = = 1 pw *= x; x *= x; n >>= 1; N >>= 1 equivalent to n/= 2 } return PW; LL N;int Main () { cin>>n; cout<<n* (6+6*n)/2+1<<endl; return 0;}
Experimental educational round:volbit formulas Blitz D