HDU2032 杨辉三角
解题思路:不要小看这题水题,如果数据类型没有用long long,
当n开为35时,会出现TLE,而且会报非法内存访问,现在还
不理解为什么,若有高手,请不吝赐教。
上代码:
#include<cstdio>
int main()
{
int n;
long long A[][];
for(int i = ; i <= ; i++)
{
for(int j = ; j <= i; j++)
{
if(i == j || j == ) A[i][j] = ;
else
{
A[i][j] = A[i-][j-] + A[i-][j];
}
}
}
while(~scanf("%d", &n))
{
for(int i = ; i <= n; i++)
{
for(int j = ; j < i; j++)
{
printf("%I64d ", A[i][j]);
}
printf("%I64d\n", A[i][i]);
}
printf("\n");
}
return ;
}
HDU2032 杨辉三角的更多相关文章
- <hdu-2032>杨辉三角
这是杭电hdu上杨辉三角的链接:http://acm.hdu.edu.cn/showproblem.php?pid=2032 Problem Description: 还记得中学时候学过的杨辉三角吗 ...
- HDU-2032.杨辉三角(C语言描述)
Problem Description 还记得中学时候学过的杨辉三角吗?具体的定义这里不再描述,你可以参考以下的图形: 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 1 5 10 10 ...
- [LeetCode] Pascal's Triangle II 杨辉三角之二
Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3,Return [1,3, ...
- [LeetCode] Pascal's Triangle 杨辉三角
Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5,Retur ...
- POJ2167Irrelevant Elements[唯一分解定理 组合数 杨辉三角]
Irrelevant Elements Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 2407 Accepted: 59 ...
- python生成器实现杨辉三角
def triangels(): """ 杨辉三角 """ lst = [1] n_count = 2 # 下一行列表长度 while Tr ...
- python 生成器生成杨辉三角
用Python写趣味程序感觉屌屌的,停不下来 #生成器生成展示杨辉三角 #原理是在一个2维数组里展示杨辉三角,空的地方用0,输出时,转化为' ' def yang(line): n,leng=0,2* ...
- HDNOIP201405杨辉三角
2016.1.27 试题描述 杨辉三角是形如如下的数字三角形: 1 1 1 1 2 1 …… 现在想求出杨辉三角第N行的N个数中,有多少个数能被给定的质数p整除. 输入 一行两个空格隔 ...
- Java的二维数组的应用及杨辉三角的编写
(1) 编写一个程序,生成一个10*10的二维随机整数数组,并将该数组的每行最大值保存于一个一维数组中,将每列平均值保存于另外一个一维数组中并分别输出. (2) 编程输出杨辉三角的前10行. 找出一个 ...
随机推荐
- Codeforces Round #397 by Kaspersky Lab and Barcelona Bootcamp (Div. 1 + Div. 2 combined) C - Table Tennis Game 2
地址:http://codeforces.com/contest/765/problem/C 题目: C. Table Tennis Game 2 time limit per test 2 seco ...
- 浏览器 Event对象 及 属性 的兼容处理
摘自: http://blog.csdn.net/jiachunfeng/article/details/6448186 event对象 IE 中可以直接使用 event 对象,而 FF 中则不可以, ...
- mysql行列互相转换
列转行: mysql> select * from test; +------+----------+-------+ | id | subject | score | +------+---- ...
- jenkins添加GIT repository报错
添加了ssh互信,但一直提示如下错误. Failed to connect to repository : Command "git ls-remote -h git@git.xxx.cn: ...
- Pyspider爬虫教程
Pyspider爬虫教程 一.安装 1. 安装pip (1)准备工作 yum install –y make gcc-c++ python-devel libxml2-devel libxslt-de ...
- Linux集群的NTP服务器时间同步
我们搭建集群环境的时候,时间必须是要统一的,才能保证集群数据的一致性. 一般操作是直接使用NTP,跟默认的时间服务器同步,但是最好还是让所有节点跟集群中的某台作为时间服务器的节点同步. 步骤:(节点有 ...
- Echarts的赋值,设置数据
柱形图案例的赋值 相关文档参考:https://blog.csdn.net/yangsitong1314/article/details/76984616 <div class="ma ...
- Windows下使用MinGW在命令行编译运行C++程序
之前学习C语言的时候都是用IDE类似CodeBlocks的工具写完直接编译运行的,今天突然心血来潮,自己下一个编译器,在命令行下,编译运行C++程序,了解一下编译过程. 一.安装编译器 首先你需要下载 ...
- TF卡.之前的(20180923)
1.京东上搜到的(购买记录) ZC:64G的应该是 只买了一个 另一个取消了 2.TB上搜到的 购买记录是这样的(注意 也有 取消的) 3. 4. 5.
- Div层弹出
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <hea ...