CodeForces 630D:Hexagons!【水】
2016-03-09 17:25
363 查看
Hexagons!
Time Limit:500MS Memory Limit:65536KB 64bit IO Format:%I64d
& %I64u
Submit Status
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.
Sample Input
Input
Output
AC-code:
Time Limit:500MS Memory Limit:65536KB 64bit IO Format:%I64d
& %I64u
Submit Status
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.
Sample Input
Input
2
Output
19
AC-code:
#include<cstdio> int main() { long long n; scanf("%lld",&n); printf("%lld\n",1+(1+n)*n*3); }
相关文章推荐
- 热烈祝贺阿尔法Go首战告捷
- 记一次用pyCharm在 virtualEnv中 创建django项目
- django定义Model中的方法和属性
- CODEFORCES630D-Hexagons!
- go os/exec执行外部程序
- 条形码、二维码以及二维码添加logo
- mongod启动时候几个参数说明
- Go随机数
- golan 3ff8 g 编译笔记,如何在指定系统下编译
- 53-题目1440:Goldbach's Conjecture
- 新浪SAE部署django博客
- 初识Golang
- [golang note] 匿名组合
- 我与小娜(30):AlphaGo赢了!
- ORA-01017: invalid username/password; logon denied
- alphago战胜李世石
- django mongoengine 判断mongoengine定义的字段类型
- 为网页添加logo图标
- Go一致性哈希库consistent
- Codeforces 86D. Powerful array (MO's Algorithm(区间查询的离线优化))