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连试试水的深浅..... ...
随机推荐
- 深入理解最强桌面地图控件GMAP.NET --- 街景地图(StreetView)
原文:深入理解最强桌面地图控件GMAP.NET --- 街景地图(StreetView) 很久没有更新博客了,今天无事把GMAP.NET的代码又重新翻了翻,看到了街景地图的例子. 街景地图是谷歌最早提 ...
- 零元学Expression Design 4 - Chapter 5 教你如何用自制笔刷在5分钟内做出设计感效果
原文:零元学Expression Design 4 - Chapter 5 教你如何用自制笔刷在5分钟内做出设计感效果 本章将教你如何运用笔刷与简单线条,只要5分钟,就能做出设计感效果 ? 本章将教你 ...
- hdu 2128 Frog(简单DP)
Frog Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Total Submi ...
- [ACM] POJ 3096 Surprising Strings (map使用)
Surprising Strings Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 5783 Accepted: 379 ...
- centos6.5安装apache2.x并更改默认80port
因为现在nginx它已成为反向代理软件的主流.因此,linuxserver在系统.我们几乎总是安装nginx东方的,这使在同一时间使用apache带来了麻烦.因为apache它用于通过缺省80port ...
- (015)实现一个函数来检查是否平衡树(keep it up)
实现一个函数来检查是否平衡树.这个问题而言. 平衡指的是这棵树随意两个叶子结点到根结点的距离之差不大于1. 这个题我们能够採用暴力搜索,找到叶子节点到根节点的最小值和最大值.然后他们的差假设大于1就不 ...
- SharePoint 2010 WebPart Web部分 总的膏
SharePoint 2010 WebPart Web部分 总的膏 之前写SharePoint WebPart Web部分相关的博客,我们没有做一个索引.网友在查看的时候非常不方便,于 ...
- Form submit
方法1:使用form onsubmit标签 return XXX()方法 <!--onsubmit--> <form id="formid" name=" ...
- ios7 获取UITablleViewCell
iOS7之前UITablleViewCell中得contentView得superView就是UITableViewCell.但是在iOS7得时候,contentView得superView确实UIT ...
- C#调用Resources.resx资源文件中的资源
使用到了.NET中的资源文件,也就是Resources.resx,于是就学会了如何调用资源文件中的资源.首先,资源文件可以从项目属性中的资源标签添加.比如,我添加一个图片,叫做aaa.png,添加入资 ...