zoukankan      html  css  js  c++  java
  • Experimental Educational Round: VolBIT Formulas Blitz D

    Description

    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.

    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.

    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.

    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
    数列,问的是周围到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 long
    using namespace std;
    LL  powl(LL x, LL n)
    {
        LL pw = 1;
        while (n > 0)
        {
            if (n & 1)        // n & 1 等价于 (n % 2) == 1
                pw *= x;
            x *= x;
            n >>= 1;        // n >>= 1 等价于 n /= 2
        }
        return pw;
    }
    LL n;
    int main()
    {
        cin>>n;
        cout<<n*(6+6*n)/2+1<<endl;
        return 0;
    }
    

      

  • 相关阅读:
    复制书稿(book) (二分,贪心+dp)
    spark0.9.1集群模式执行graphx測试程序(LiveJournalPageRank,新增Connected Components)
    java 的File文件
    最长公共字序列.cpp
    产品级敏捷开发关键的第一步: 制订版本号公布的节奏
    MySQL优化之——触发器
    Android 打造随意层级树形控件 考验你的数据结构和设计
    【Android】Android聊天机器人实现
    Mysql用户权限管理
    Android经常使用的工具类
  • 原文地址:https://www.cnblogs.com/yinghualuowu/p/5208385.html
Copyright © 2011-2022 走看看