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. python类和实例以及__call__/__del__

    面向对象最重要的概念就是类(Class)和实例(Instance),必须牢记类是抽象的模板,比如Student类,而实例是根据类创建出来的一个个具体的“对象”,每个对象都拥有相同的方法,但各自的数据可 ...

  2. 5.synchronized锁重入

    package demo1; /** * synchronized锁重入 * Created by liudan on 2017/6/5. */ public class MyThread5_sync ...

  3. 版本号控制-git(二)

    上次文章给大家介绍了Git的一些基本知识(http://www.cnblogs.com/jerehedu/p/4582398.html).并介绍了使用git init初始化化版本号库.使用git ad ...

  4. 使用FastDateFormat来代替JDK自带的DateFormat

    之前一直使用SimpleDateFormat来做Date到String的类型转换,现建议使用apache commons-lang3中的FastDateFormat. 因为JDK里自带的SimpleD ...

  5. 混沌数学之离散点集图形DEMO

    最近看了很多与混沌相关的知识,并写了若干小软件.混沌现象是个有意思的东西,同时混沌也能够生成许多有意思的图形.混沌学的现代研究使人们渐渐明白,十分简单的数学方程完全可以模拟系统如瀑布一样剧烈的行为.输 ...

  6. Python中的乱码

        我把写好的Python脚本导入到ArcGIS中的ToolBox中,在本机测试是没有问题的.为了把工具分享给其他人,即在其他电脑上使用,我必须将脚本文件(*.py)导入到工具箱文件(*.tbx) ...

  7. Oracle 与 SqlServer 的区别浅析总结

    我主要用过的数据库为Oracle10g和SqlServer2008,通过实际运用和查阅资料整理如下: 主题 Oracle 10g SQLServer 2008 存储过程格式 Create Or Rep ...

  8. 【读书笔记】Flickr 网站用户标签的质量控制对策

    1.一些背景 标签技术重要意义 标签技术如今已经被广泛应用于包括网络书签.博客.播客.视频分享等在内的多种 Web2. 0 服务 Flickr简介 Flickr 是一集图片存放 交友 组群 邮件等功能 ...

  9. 【IPC进程间通讯之二】管道Pipe

    IPC进程间通信+管道Pipe                IPC(Inter-Process Communication.进程间通信).         管道用于进程间共享数据,事实上质是共享内存 ...

  10. 一些面试基本知识(Android篇一)

    Android Activity设计模式之MVC模式(介绍MVP之前的引子) 參考博客.文章 http://www.cnblogs.com/liqw/p/4175325.html MVC即Model- ...