Counting Triangles

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 1882    Accepted Submission(s): 898

Problem Description
Given an equilateral triangle with n the length of its side, program to count how many triangles in it.

 
Input
The length n (n <= 500) of the equilateral triangle's side, one per line.

process to the end of the file

 
Output
The number of triangles in the equilateral triangle, one per line.
 
Sample Input
1 2 3
 
Sample Output
1 5 13
 
Author
JIANG, Jiefeng
 
Source
Recommend
Ignatius.L
规律在这:
 
代码:
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
int n;
int sum;
while(cin>>n)
{
sum=n*(n+)*(*n+);
if(n&) sum--;
printf("%d\n",sum/);
}
return ;
}

HDUOJ-Counting Triangles的更多相关文章

  1. hdu 1396 Counting Triangles(递推)

    Counting Triangles Problem Description Given an equilateral triangle with n thelength of its side, p ...

  2. Counting Triangles(hd1396)

    Counting Triangles Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Other ...

  3. UVA 12075 - Counting Triangles(容斥原理计数)

    题目链接:12075 - Counting Triangles 题意:求n * m矩形内,最多能组成几个三角形 这题和UVA 1393类似,把总情况扣去三点共线情况,那么问题转化为求三点共线的情况,对 ...

  4. 1307 - Counting Triangles

    1307 - Counting Triangles    PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: 32 ...

  5. LA 3295 (计数 容斥原理) Counting Triangles

    如果用容斥原理递推的办法,这道题确实和LA 3720 Highway很像. 看到大神们写的博客,什么乱搞啊,随便统计一下,这真的让小白很为难,于是我决定用比较严格的语言来写这篇题解. 整体思路很简单: ...

  6. UVALive 3295 Counting Triangles

    题目链接:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_ ...

  7. UVA 12075 Counting Triangles

    https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_probl ...

  8. UVA 1393 Highways,UVA 12075 Counting Triangles —— (组合数,dp)

    先看第一题,有n*m个点,求在这些点中,有多少条直线,经过了至少两点,且不是水平的也不是竖直的. 分析:由于对称性,我们只要求一个方向的线即可.该题分成两个过程,第一个过程是求出n*m的矩形中,dp[ ...

  9. Codestorm:Counting Triangles 查各种三角形的个数

    题目链接:https://www.hackerrank.com/contests/codestorm/challenges/ilia 这周六玩了一天的Codestorm,这个题目是真的很好玩,无奈只做 ...

随机推荐

  1. sudo:抱歉,您必须拥有一个终端来执行 sudo 解决办法;ssh执行sudo命令的方法;给用户增加sudo免密权限

    1.supervisor使用sudo执行命令的时候,报错 2.解决办法: 编辑 /etc/sudoers 文件,将Default requiretty注释掉. sudo vim /etc/sudoer ...

  2. Hadoop目录

    1. 通过java读取HDFS的数据 (转) 2. FLume监控文件夹,将数据发送给Kafka以及HDFS的配置文件详解 3. 开启hadoop和Hbase集群的lzo压缩功能(转) 4. Hado ...

  3. 使用Java、Matlab画多边形闭合折线图

    由于写论文要将“哈密顿回路问题(TSP)”的求解中间结果表示出来,查了一下使用程序画多边形图形.现在在总结一下,这个图是“由给定节点首尾相连的”闭合多边形. 1.使用matlab作闭合多边形图 没有找 ...

  4. MySQL语法大全

    select * from emp; #注释 #--------------------------- #----命令行连接MySql--------- #启动mysql服务器 net start m ...

  5. ScaleIO与XtremSW Cache如何集成呢?

    在ScaleIO上, XtremSW Cache主要有两种部署方式: 把XtremSW Cache在每台server的内部用作cache - 在ScaleIO Data Server(SDS)下做ca ...

  6. Git 忽略规则 .gitignore文件 MD

    Markdown版本笔记 我的GitHub首页 我的博客 我的微信 我的邮箱 MyAndroidBlogs baiqiantao baiqiantao bqt20094 baiqiantao@sina ...

  7. 【Gson】简介 文档 基本使用 示例

    简介 new TypeToken<List<Person>>() {}.getType() 1 1   1 new TypeToken<List<Person> ...

  8. Java 解析Excel文件为JSON

    Excel转Json的需求 反正我对SSM基本不会的情况下来到现在这家公司,都是90后,感觉很好.第二天就给我开发任务,就是把用户上传的Excel文件转成JSON返回给前台用于大屏的数据展示. 解决方 ...

  9. html 空白汉字占位符

     可以看作一个空白的汉字 == 普通的英文半角空格   ==   ==   == no-break space (普通的英文半角空格但不换行)   == 中文全角空格 (一个中文宽度)   ==   ...

  10. 在Win7上安装MySql5.2遇到Write configuration file的解决

    机器从XP翻新到Win7后,原有的环境也被清除了,因此找了个时间重新安装MySql. 以前轻车熟路的过程,在最后一环却卡住了,出现Write configuration file 错误. 以前从来没有 ...