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 geometric figures Alex has accidentally invented a concept of an-th order rhombusin a cell grid.A1-st order rhombusis just a square1×1(i.e just a cell).An-th order rhombusfor alln≥2one obtains from an−1-th order rhombusadding 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 n-th order rhombus.
InputThe first and only input line contains integern(1≤n≤100) — order of a rhombus whose numbers of cells should be computed.
OutputPrint exactly one integer — the number of cells in a n-th order rhombus.

Examples
Input
1
Output
1
Input
2
Output
5
Input
3
Output
13
NoteImages of rhombus corresponding to the examples are given in the statement.
题意:求第N个图形的小方格个数
思路:
找规律题:
1+3+5+7+..+5+3+1
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const int maxn=2e5+;
ll ji[maxn];
int main()
{
int n;
while(cin>>n) {
ll ji[maxn];
ji[]=;
for(int i=;i<;i++)
{
ji[i]=ji[i-]+;
}
if (n == )
cout << << endl;
else if (n == )
cout << << endl;
else {
ll sum = ;
for (int i = ; i <= n - ; i++)
{
sum += ji[i];
}
cout << * sum + ji[n - ] << endl;
}
}
return ;
}
Codeforces Round #569 (Div. 2)A. Alex and a Rhombus的更多相关文章
- 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 #569 (Div. 2) C. Valeriy and Deque
链接: https://codeforces.com/contest/1180/problem/C 题意: Recently, on the course of algorithms and data ...
- Codeforces Round #569 (Div. 2) B. Nick and Array
链接: https://codeforces.com/contest/1180/problem/B 题意: Nick had received an awesome array of integers ...
- Codeforces Round #569 Div. 1
A:n-1次操作后最大值会被放到第一个,于是暴力模拟前n-1次,之后显然是循环的. #include<bits/stdc++.h> using namespace std; #define ...
- Codeforces Round #485 (Div. 2) E. Petr and Permutations
Codeforces Round #485 (Div. 2) E. Petr and Permutations 题目连接: http://codeforces.com/contest/987/prob ...
- Codeforces Round #366 (Div. 2) ABC
Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...
- Codeforces Round #354 (Div. 2) ABCD
Codeforces Round #354 (Div. 2) Problems # Name A Nicholas and Permutation standard input/out ...
- Codeforces Round #368 (Div. 2)
直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...
- cf之路,1,Codeforces Round #345 (Div. 2)
cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅..... ...
随机推荐
- 改变TLabel字型和颜色(Styled特性高于自身特性,李维的博客)
最近收到几位使用者的来信都是和如何改变FireMonkey TLabel组件的字型和颜色, 这几位使用者都是直接改变TextSettings特性中的Font子特性但却无法改变字型和颜色, 因此来信询问 ...
- OpenCV中基于HOG特征的行人检测
目前基于机器学习方法的行人检测的主流特征描述子之一是HOG(Histogram of Oriented Gradient, 方向梯度直方图).HOG特征是用于目标检测的特征描述子,它通过计算和统计图像 ...
- matlab 类型转换(类型判断)
char:Convert to character array,转换为字符数组:matlab 下没有 str 字符串类型转换: char(0-255) ⇒ ASCII 码的转换: im2double( ...
- hann function
hann function 是一种离散型窗函数,定义如下: w(n)=12(1−cos(2πnN−1))=sin2(πnN−1) 窗口的长度为 L=N+1; hann function 以及其傅里叶响 ...
- Linux技术学习路线图
- 最简单的IdentityServer实现——IdentityServer
1.新建项目 新建ASP .Net Core项目IdentityServer.EasyDemo.IdentityServer,选择.net core 2.0 1 2 引用IdentitySer ...
- mysql数据库编码、字段编码、表编码 专题
CREATE DATABASE `mybatis-subject` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin */ 其中的 ...
- WPF4.0用tablet实现手写输入(更新XP SP3下也能手写输入方法)
原文:WPF4.0用tablet实现手写输入(更新XP SP3下也能手写输入方法) 由于项目需求一个手写输入的控件,纠结了2天,终于搞定了. 主要是由于本人的英语不过关,一直和ocr混淆在一起,研究了 ...
- js错误界面
<!DOCTYPE html><html><head><meta http-equiv="Content-Type" content=&q ...
- WPF判断两个PNG图片是否碰撞
这个方法有几个前提 1.两个Image必须在一个Canvas中 2.两个Image的Canvas.Top和Canvas.Left必须赋值 上一篇讲了判断一个PNG图片某个点是否透明 这个基本类似的方法 ...