Codeforces--630D--Hexagons(规律)
Hexagons!
Crawling in process...
Crawling failed
Time Limit:500MS
Memory Limit:65536KB 64bit IO Format:%I64d & %I64u
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
2
19
1,6,12,18....明显就是1,1*6,2*6,3*6....除了第一项,就是一个等差序列带公式就行了
#include<iostream>
using namespace std;
#define LL long long
int main()
{
LL n;
cin>>n;
cout<<n*(6+6*n)/2+1<<endl;
return 0;
}
Codeforces--630D--Hexagons(规律)的更多相关文章
- codeforces 630D Hexagons!
D. Hexagons! time limit per test 0.5 seconds memory limit per test 64 megabytes input standard input ...
- codeforces 615E Hexagons (二分+找规律)
E. Hexagons time limit per test 1 second memory limit per test 256 megabytes input standard input ou ...
- codeforces 362A找规律
刚开始以为是搜索白忙活了原来是个简单的找规律,以后要多想啊 此题是两马同时跳 A. Two Semiknights Meet time limit per test 1 second memory l ...
- codeforces——思路与规律
codeforces 804B http://codeforces.com/problemset/problem/804/B /* 题意:给定一个只含ab的序列,每次操作可将ab变为bba 问 ...
- Nastya and a Wardrobe CodeForces - 992C(规律)
写一下二叉树 推一下公式就出来了, 注意取模时的输出形式 #include <bits/stdc++.h> #define mem(a, b) memset(a, b, sizeof(a ...
- Codeforces 145A-Lucky Conversion(规律)
A. Lucky Conversion time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- codeforces D. Queue 找规律+递推
题目链接: http://codeforces.com/problemset/problem/353/D?mobile=true H. Queue time limit per test 1 seco ...
- Codeforces Gym 100015A Another Rock-Paper-Scissors Problem 找规律
Another Rock-Paper-Scissors Problem 题目连接: http://codeforces.com/gym/100015/attachments Description S ...
- Codeforces Round #338 (Div. 2) E. Hexagons 讨论讨论
E. Hexagons 题目连接: http://codeforces.com/contest/615/problem/E Description Ayrat is looking for the p ...
- Codeforces Round #347 (Div. 2) C. International Olympiad 找规律
题目链接: http://codeforces.com/contest/664/problem/C 题解: 这题最关键的规律在于一位的有1989-1998(9-8),两位的有1999-2098(99- ...
随机推荐
- Android_撕衣服小案例
一直都觉得做安卓开发挺有意思,最近一段时间都在学习这方面的知识以及练习敲代码这次要说的是一个简单有趣的案例,相信大家也是看了标题才进来的吧,是不是有点迫不及待的想看看效果图,嘿嘿,算了还是直接给上源码 ...
- 01--Java开发中文乱码问题分析
一.常见的编码格式 1. ASCII码 总共128个字符,用1个字节的低7位表示,0~31是控制字符,32~126是打印字符. 2. ISO-8859-1 ISO组织在ASCII基础上进行扩展,仍是 ...
- ibatis知识点
1:ibatis是apache的一个开源的项目,是一个O/R mapping解决方案,优点,小巧,灵活.2:搭建环境:导入ibatis相关jar包,jdbc驱动包等3:配置文件: jdbc连接的属性文 ...
- 【译】x86程序员手册15-5.2页转换
5.2 Page Translation 页转换 In the second phase of address transformation, the 80386 transforms a linea ...
- (转) Arcgis for Javascript实现两个地图的联动
http://blog.csdn.net/gisshixisheng/article/details/40127895 今天在看天地图的时候,有一个多时相的地图显示功能,感觉很好玩,作为技术控的我晚上 ...
- python dns请求
一.DNS dns(domain name system)域名系统 ,主要用来把主机名转换成ip地址.其至今能存在的原因有两个: 能使人们记住名字,而不是ip地址: 允许服务器改变地址,但使用相同的名 ...
- Git学习总结三(工作区和暂存区、撤销修改)
工作区和暂存区 工作区(Working Directory) 就是你在电脑里能看到的目录,比如我的learngit文件夹就是一个工作区: 版本库(Repository) 工作区有一个隐藏目录.git, ...
- Lua操作符的优先级
lua 操作符的优先级 lua操作符的优先级 如表所示(从高到低) 在二元操作符中,除了指数操作符 “^” 和连接操作符 “..” 是 ”右结合” 的,是所有其他操作符都是 “左结合” 的.因此如 ...
- matplotlib命令与格式:标题(title),标注(annotate),文字说明(text)
1.title设置图像标题 (1)title常用参数 fontsize设置字体大小,默认12,可选参数 ['xx-small', 'x-small', 'small', 'medium', 'la ...
- Git 基础教程 之 搭建Git服务器
截图自: 廖雪峰老师官方网站 https://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000/0 ...