[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 ...
随机推荐
- 短uuid生成
UUID UUID是128位的全局唯一标识符,通常由32字节的字符串表示.它可以保证时间和空间的唯一性,python中称为UUID,其他语言中可能称为GUID. 它通过MAC地址.时间戳.命名空间.随 ...
- 微信2.1 for Windows发布 微信群可多人语音或视频通话
5月31日,windows电脑版微信发布更新,微信2.1 for Windows带来最主要的功能是微信群可以多人语音或视频通话了,建个家庭群组,常年在外工作的家人也可以每天见面了,多亲切! 除了可以建 ...
- idea每次新建项目的默认路径
idea每次新建项目的默认路径 每次新建项目的默认路径是上一次新建项目所在的文件夹.第一次需要手动切换.
- mysql命令查询语句&MTdata
1.单表查询 select * from student; 采用*效率低,不推荐,多用列名 一.单表查询的语法: SELECT 字段1,字段2... FROM 表名 WHERE 条件 GROUP BY ...
- linux command lynx
[Purpose] Learning linux command lynx [Eevironment] Ubuntu 16.04 terminal apt-get ...
- prototype、__proto__、constructor
prototype:每个函数都有一个prototype属性,这个属性指向一个对象,这个对象叫原型对象. 作用:节约内存.扩展属性和方法.可以实现类之间的继承 __proto__:每个通过构造函数new ...
- 牛客NOIP暑期七天营-提高组1
牛客NOIP暑期七天营-提高组1 链接 A 边权可为0就排序建一条链子. 但是边权不为0 除了第一个有0的不行. x连向上一个比他小的数. 期间判断有无解. #include <bits/std ...
- 【border相关】【P3426】 [POI2005]SZA-Template
[border相关][P3426] [POI2005]SZA-Template Description 给定一个字符串 \(S\),要求一个最短的字符串 \(T\),使得 \(S\) 可以由 \(T\ ...
- PATA1055 The World's Richest (25 分)
1055 The World's Richest (25 分) Forbes magazine publishes every year its list of billionaires based ...
- map函数怎么用咧↓↓↓
Map是c++的一个标准容器,她提供了很好一对一的关系,在一些程序中建立一个map可以起到事半功倍的效果,总结了一些map基本简单实用的操作! 1. map最基本的构造函数: map<st ...