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. 绑定到异步的ObservableCollection

    原文:绑定到异步的ObservableCollection 在进行WPF开发过程中,需要从一个新的线程中操作ObservableCollection,结果程序抛出一个NotSupportedExcep ...

  2. svm资料收集

    向量点乘(内积)和叉乘(外积.向量积)概念及几何意义解读: https://blog.csdn.net/dcrmg/article/details/52416832 三角形余弦定理:https://z ...

  3. 031 二进制1的数量(keep it up, 看到这个问题,刚开始有点蒙)

    剑指offer在标题中:http://ac.jobdu.com/problem.php?pid=1513 题目描写叙述: 输入一个整数,输出该数二进制表示中1的个数.当中负数用补码表示. 输入: 输入 ...

  4. CefSharp中ChromiumWebBrowser打开新页面处理(_blank)

    原文:CefSharp中ChromiumWebBrowser打开新页面处理(_blank) 版权声明:欢迎转载,但是请保留出处说明 https://blog.csdn.net/lanwilliam/a ...

  5. 开源 自由 java CMS - FreeCMS1.9 积分规则管理

    项目地址:http://www.freeteam.cn/ 积分规则管理 管理会员操作时积分处理规则. 1. 积分规则管理 从左側管理菜单点击积分规则进入. 2. 加入积分规则 在积分规则列表下方点击& ...

  6. 关于fastjson用法

    fastjson 是一个性能很好的 Java 语言实现的 JSON 解析器和生成器,来自阿里巴巴的工程师开发. public static final String toJSONString(Obje ...

  7. WPF 流打印

    原文:WPF 流打印 PrintDialog printDialog = new PrintDialog(); if (printDialog.ShowDialog() == true) { Syst ...

  8. 【C#】WPF的xaml中定义的Trigger为什么有时候会不管用,如Border的MouseOver之类的

    原文:[C#]WPF的xaml中定义的Trigger为什么有时候会不管用,如Border的MouseOver之类的 初学WPF,知道一些控件可以通过定义Style的Trigger改变要显示的样式,但是 ...

  9. xadmin 无法创建xadmin_log 或者是xadmin源代码使用,没有引用xadmin包报错或 1146, "Table 'mxonline.xadmin_log' doesn't exist"

    解决方案: 第一步:将xadmin所在的目录为source_root 第二步:在settings.py中引用xadmin所在的目录 第三步makemigrations和migrate 引起原因:主语是 ...

  10. 深入理解Amazon Alexa Skill(三)

    本节来讨论Alexa Skill中涉及到的授权问题. Alexa内功能的授权 Alexa会发给skill用户的token,然后skill代码使用这个token来访问Web API访问用户的Alexa内 ...