[Codeforces] Alex and a Rhombus
1 second
256 megabytes
standard input
standard output
While playing with geometric figures Alex has accidentally invented a concept of a nn-th order rhombus in a cell grid.
A 11-st order rhombus is just a square 1×11×1 (i.e just a cell).
A nn-th order rhombus for all n≥2n≥2 one obtains from a n−1n−1-th order rhombus adding all cells which have a common side with it to it (look at the picture to understand it better).
Alex asks you to compute the number of cells in a nn-th order rhombus.
The first and only input line contains integer nn (1≤n≤1001≤n≤100) — order of a rhombus whose numbers of cells should be computed.
Print exactly one integer — the number of cells in a nn-th order rhombus.
1
1
2
5
3
13
Images of rhombus corresponding to the examples are given in the statement.
算格子數
就是等差數列 1 + 3 + 5 + ....
最後一塊 last = n * 2 -1; 這個會重複
class Program
{
static void Main(string[] args)
{
Console.WriteLine(Solution.Compute(Convert.ToInt32(Console.ReadLine())));
}
} class Solution
{
public static int Compute(int n)
{
int last = n * - ;
return ( + last) * n - last;
}
}
[Codeforces] Alex and a Rhombus的更多相关文章
- Codeforces Round #569 (Div. 2)A. Alex and a Rhombus
A. Alex and a Rhombus 题目链接:http://codeforces.com/contest/1180/problem/A 题目: While playing with geome ...
- Codeforces Round #569 (Div. 2) 题解A - Alex and a Rhombus+B - Nick and Array+C - Valeriy and Dequ+D - Tolik and His Uncle
A. Alex and a Rhombus time limit per test1 second memory limit per test256 megabytes inputstandard i ...
- Codeforces Round #542 [Alex Lopashev Thanks-Round] (Div. 2) 题解
Codeforces Round #542 [Alex Lopashev Thanks-Round] (Div. 2) 题目链接:https://codeforces.com/contest/1130 ...
- Codeforces Round #586 (Div. 1 + Div. 2) D. Alex and Julian
链接: https://codeforces.com/contest/1220/problem/D 题意: Boy Dima gave Julian a birthday present - set ...
- 【Codeforces 1097F】Alex and a TV Show(bitset & 莫比乌斯反演)
Description 你需要维护 \(n\) 个可重集,并执行 \(m\) 次操作: 1 x v:\(X\leftarrow \{v\}\): 2 x y z:\(X\leftarrow Y \cu ...
- Codeforces Round #542 [Alex Lopashev Thanks-Round] (Div. 1) C(二分+KMP)
http://codeforces.com/contest/1129/problem/C #include<bits/stdc++.h> #define fi first #define ...
- Codeforces Round #542 [Alex Lopashev Thanks-Round] (Div. 2) A - D2
A. Be Positive 链接:http://codeforces.com/contest/1130/problem/A 题意: 给一段序列,这段序列每个数都除一个d(−1e3≤d≤1e3)除完后 ...
- 【Codeforces Round 1129】Alex Lopashev Thanks-Round (Div. 1)
Codeforces Round 1129 这场模拟比赛做了\(A1\).\(A2\).\(B\).\(C\),\(Div.1\)排名40. \(A\)题是道贪心,可以考虑每一个站点是分开来的,把目的 ...
- CodeForces - 1097F:Alex and a TV Show (bitset & 莫比乌斯容斥)
Alex decided to try his luck in TV shows. He once went to the quiz named "What's That Word?!&qu ...
随机推荐
- Linux使用pt-archiver工具自动备份MySQL
操作系统: CentOS 6.9 脚本语言: shell https://github.com/iscongyang/Practical/blob/master/shell-scripts/pt-ar ...
- UDP基础
UDP主要特点: (1)UDP是无连接的,发送数据不需要建立连接,减少了开销和发送数据之前的时延. (2)UDP使用尽最大努力交付,即不保证可靠交付,因此主机不需要维持连接状态表. (3)UDP面向报 ...
- 使用WIFI网卡 dhcp动态获取IP
前面几篇博客中,wifi网卡的ip都是手工设置的,本篇博客将来移植dhcp,使得wifi网卡可以动态的获取ip.路由等信息. 那我们去哪里下载dhcp源码呢?在pc机上执行dh +tab键,看一下有哪 ...
- 201871010105-曹玉中《面向对象程序设计(Java)》第二周学习总结
201871010105-曹玉中<面向对象程序设计(Java)>第二周学习总结 项目 ...
- wordpress后台添加左侧边栏菜单如何操作
我们有时为了方便操作会把一些特定的链接添加到wordpress后台左侧菜单栏中,这个要如何实现呢?其实不会很难,使用两个WordPress内置函数就可以解决问题,分别是add_menu_page()和 ...
- 1. vue 的安装
兼容性 Vue 不支持 IE8 及以下版本,因为 Vue 使用了 IE8 无法模拟的 ECMAScript 5 特性.但它支持所有兼容 ECMAScript 5 的浏览器. 安装: 1.直接用 < ...
- MAC上配置idea环境时排查问题
现象:没有使用走公司maven仓库的setting.xml文件时,只有公司内部依赖 没有找到在idea的maven配置中指定 公司setting.xml后,所有的文件都提示找不到 解决办法:把公司se ...
- 单例模式-DCL双重锁检查实现及原理刨析
以我的经验为例(如有不对欢迎指正),在生产过程中,经常会遇到下面两种情况: 1.封装的某个类不包含具有具体业务含义的类成员变量,是对业务动作的封装,如MVC中的各层(HTTPRequest对象以Thr ...
- centos6中安装新版 Elasticsearch 7.x
es出新版了,虽然公司里还是用的老版本,但是本地还是有必要自己安装了玩玩 下载地址:https://www.elastic.co/cn/downloads/elasticsearch 那么一般来说还是 ...
- Oracle_本地计算机上的OracleOraDb11g_home1TNSListener 服务启动后停止
这个IP地址要写对,写成本机IP4的地址