Experimental educational round:volbit formulas Blitz D

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.