Codeforces Experimental Educational Round: VolBIT Formulas Blitz D. Hexagons!
来源:互联网 发布:单反推荐 知乎 编辑:程序博客网 时间:2024/05/30 05:41
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.
The only line of the input contains one integer n (0 ≤ n ≤ 109).
Output one integer — the number of hexagons situated not farther than n cells away from a given cell.
2
19
1: 7
2: 19
3: 37
4: 61
很显然推出一个公式:n*(n+1)*3+1
#include <bits/stdc++.h>using namespace std;int main(){ long long n; cin>>n; cout<<(n+1)*n*3+1<<endl; return 0;}
- Codeforces Experimental Educational Round: VolBIT Formulas Blitz D. Hexagons!
- Experimental Educational Round: VolBIT Formulas Blitz(D)数学
- Experimental Educational Round: VolBIT Formulas Blitz
- Experimental Educational Round: VolBIT Formulas Blitz题解
- Experimental Educational Round: VolBIT Formulas Blitz 公式题
- Experimental Educational Round: VolBIT Formulas Blitz(A)数学
- Experimental Educational Round: VolBIT Formulas Blitz(B)快速幂
- Experimental Educational Round: VolBIT Formulas Blitz(F)排列组合
- Experimental Educational Round: VolBIT Formulas Blitz(J)打表找规律
- Experimental Educational Round: VolBIT Formulas Blitz(R)博弈
- Experimental Educational Round: VolBIT Formulas Blitz(数学、组合数学)
- Experimental Educational Round: VolBIT Formulas Blitz-R. Game
- CodeForces Experimental Educational Round: VolBIT Formulas Blitz A. Again Twenty Five!
- codeforcesExperimental Educational Round: VolBIT Formulas Blitz
- Experimental Educational Round: VolBIT Formulas Blitz K. Indivisibility —— 容斥原理
- Educational Codeforces Round 21-D
- Educational Codeforces Round 5 D
- Educational Codeforces Round 26 D
- error: stray ‘\302’ in program 处理
- 数据结构--1、线性表
- 关于编译性语言、解释性语言和脚本语言,动态语言,静态语言的区别
- Java中==与equals方法的区别
- Android层测试摄像头实际输出帧率大小
- Codeforces Experimental Educational Round: VolBIT Formulas Blitz D. Hexagons!
- OOA/OOD/OOP的区别
- android中finish()与system.exit(0)的区别?
- 数据结构之栈(四)
- 设计模式 命令模式 之 管理智能家电
- 图像模式
- SpringMVC中url-parden配置的问题和SpringMVC中js、css不生效问题
- vs2013窗口布局恢复
- Inno Setup中控件的创建及事件响应