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连试试水的深浅..... ...
随机推荐
- 两个QWidget叠加,可部分代替layout的功能
在QT开发过程中,有时候会遇到这样的问题,当我们自己创建了一个Layout对象以后,使用QWidget的setLayout方法,将这个Layout对象应用到窗口中的时候,发现窗口上没有我们添加的控件, ...
- matlab 微积分
符号变量,symbolic variable 1. 高阶导数 高阶导数的计算,当然可以用手工的方式,但显然这种机械重复的推导,更适用于计算机的计算方式: f(x)=sinxx2+4x+3⇒d4fdx4 ...
- 怎么样android app正在使用STL库
方法: 1.在jni文件夹下新建Application.mk; 增加 APP_STL := stlport_static右边的值还能够换成以下几个: system - 使用默认最小的C++执行库,这样 ...
- 关闭Mac OS 的Rootless
今天在使用mac的时候,需要删除 /usr/bin/下的 自带的php文件.然后提示Operation not permitted 使用sudo 依然不可以,通过google 得到解决方案. 需要关闭 ...
- sql like N'%...%' 在C#里的写法
StringBuilder sb = new StringBuilder(); List<SqlParameter> parameters =new List<SqlParamete ...
- WPF 动态绑定listview的列内容
Binding binding = new Binding(); binding.Path = new PropertyPath("State"); listViewState.D ...
- Spring Boot 专题
Spring is a very popular Java-based framework for building web and enterprise applications. Unlike m ...
- 微信小程序把玩(十四)button组件
原文:微信小程序把玩(十四)button组件 button按钮用的算是最普遍的组件之一. 主要属性: wxml <!--按钮默认样式,点击事件--> <button type=&qu ...
- oh my zsh安装
引言 最近阿里云搞活动,整了一台服务器,作为Linux的爱好者,又免费,so.......当然不能错过了.以前看到好多炫酷的Linux界面,比如这样的:梦想中…… 通过各种方式得知这是Oh my zs ...
- VS中添加第三方库及相对路径设置
原文 VS中添加第三方库及相对路径设置 对于一些第三方的SDK,一般会包含头文件(*.h),静态库文件(*.lib)和动态库文件(*.dll). 1. 文件位置:为了提高程序的可移植性,将第三库放在 ...