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的更多相关文章

  1. 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 ...

  2. Codeforces Round #569 (Div. 2) C. Valeriy and Deque

    链接: https://codeforces.com/contest/1180/problem/C 题意: Recently, on the course of algorithms and data ...

  3. Codeforces Round #569 (Div. 2) B. Nick and Array

    链接: https://codeforces.com/contest/1180/problem/B 题意: Nick had received an awesome array of integers ...

  4. Codeforces Round #569 Div. 1

    A:n-1次操作后最大值会被放到第一个,于是暴力模拟前n-1次,之后显然是循环的. #include<bits/stdc++.h> using namespace std; #define ...

  5. Codeforces Round #485 (Div. 2) E. Petr and Permutations

    Codeforces Round #485 (Div. 2) E. Petr and Permutations 题目连接: http://codeforces.com/contest/987/prob ...

  6. 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 ...

  7. Codeforces Round #354 (Div. 2) ABCD

    Codeforces Round #354 (Div. 2) Problems     # Name     A Nicholas and Permutation standard input/out ...

  8. Codeforces Round #368 (Div. 2)

    直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...

  9. cf之路,1,Codeforces Round #345 (Div. 2)

     cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅.....   ...

随机推荐

  1. 机器学习、深度学习实战细节(batch norm、relu、dropout 等的相对顺序)

    cost function,一般得到的是一个 scalar-value,标量值: 执行 SGD 时,是最终的 cost function 获得的 scalar-value,关于模型的参数得到的: 1. ...

  2. SecureCRT自动登录Linux并设置时间

    #$language = "VBScript" #$interface = "1.0" crt.Screen.Synchronous = True ' This ...

  3. matlab 正态分布相关 API

    randn:标准正太分布(μ=0,σ=1) normrnd:正态分布随机数,(需要手动指定 μ,σ,二者均是标量) mvnrnd:多变量正态分布随机数,(需要手动指定 μ,σ(二者为向量))

  4. Matlab随笔之插值与拟合(下)

    原文:Matlab随笔之插值与拟合(下) 1.二维插值之插值节点为网格节点 已知m x n个节点:(xi,yj,zij)(i=1…m,j=1…n),且xi,yi递增.求(x,y)处的插值z. Matl ...

  5. Java程序猿的书面采访String3

    public class SameString { //思想二:每个字符都相应着自己的ASC码,第一个思想的算法复杂度为O(nlogn).一般能够利用空间来减少时间复杂度 //能够开辟一个大小为256 ...

  6. CentOS 7.3最小系统安装KVM

    一.准备工作 安装wget和vim yum install -y wget vim 修改yum源为阿里源 wget -O /etc/yum.repos.d/CentOS-Base.repo http: ...

  7. IOS开发之关于NSString和NSMutableString的retainCount

    1. 字符串常量 NSString *s = @"test"; NSLog(@"s:%lx",[s retainCount]); //fffffffffffff ...

  8. 生成view的描述字段列表

    ); declare @field_list nvarchar(max); set @table = N'vwMaterial'; set @field_list = N''; SELECT u.na ...

  9. 基于VUE实现的新闻后台管理系统-二

    基础环境及最后的开发效果已完成说明,接下来就开始配置. ¶npm初始化 新建项目文件夹VueDemo,在其内执行如下脚本 npm init -y 安装vue-cli构建包 yarn add vue-c ...

  10. Elevate Web Builder for Web Developers(类似于unigui的东西)

    推荐一款pascal 语言的web 开发工具 这几天仔细研究了一款使用Pascal 语言开发web 的工具 具体介绍可以参照这里. 先上几张他开发的页面照.