摘要: 题目:http://acm.nyist.net/JudgeOnline/problem.php?pid=93判断给你的操作是否满足要求:使用三个栈来操作,模拟该过程 1 #include<stdio.h> 2 #include <string.h> 3 4 #define N 105 5 6 int a[4][N]; 7 int f[N][2]; 8 9 void init(int n)//初始化栈 第一根柱子 10 { 11 memset(a,0,sizeof(a)); 12 13 int i; 14 int t = 1; 15 f... 阅读全文
posted @ 2013-04-24 17:21 heity 阅读(198) 评论(0) 推荐(0) 编辑
摘要: 三角形Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 3416Accepted Submission(s): 2368Problem Description用N个三角形最多可以把平面分成几个区域?Input输入数据的第一行是一个正整数T(1<=T<=10000),表示测试数据的数量.然后是T组测试数据,每组测试数据只包含一个正整数N(1<=N<=10000).Output对于每组测试数据,请输出题目中要求的结果.Samp 阅读全文
posted @ 2013-04-23 12:09 heity 阅读(119) 评论(0) 推荐(0) 编辑
摘要: 汉诺塔问题,给你四个柱子,要把所有的盘子从1 移到 3 上1------12 -----33 ------54-------95 -------136--------177 -------25要是按着先把n-3个盘子移到另一个柱子上这样就有一个递推公式,f[n] = 2[n - 3] + 2 ^3-1用12带进去发现不对,不知道为什么,后来yy了一下,能够找出关系,希望大牛指点。。。。 1 #include <stdio.h> 2 #include <string.h> 3 #include <math.h> 4 5 long long a[65]; 6 7 阅读全文
posted @ 2013-04-23 11:35 heity 阅读(156) 评论(0) 推荐(0) 编辑
摘要: Problem DescriptionIn how many ways can you tile a 3xn rectangle with 2x1 dominoes? Here is a sample tiling of a 3x12 rectangle.InputInput consists of several test cases followed by a line containing -1. Each test case is a line containing an integer 0 ≤ n ≤ 30. OutputFor each test case, output one 阅读全文
posted @ 2013-04-23 08:54 heity 阅读(185) 评论(0) 推荐(0) 编辑
摘要: 卡特兰数真是一个神奇的数字,很多组合问题的数量都和它有关系,例如: Cn= 长度为 2n的 Dyck words的数量。 Dyck words是由 n个 X和 n个 Y组成的字符串,并且从左往右数, Y的数量不超过 X,例如长度为 6的 Dyck words为: XXXYYY XYXXYY XYXYXY XXYYXY XXYXYY Cn= n对括号正确匹配组成的字符串数,例如 3对括号能够组成: ((())) ()(()) ()()() (())() (()()) Cn= n+1个数相乘,所有的括号方案数。例如, 4个数相乘的括号方案为: ((ab)c)d (a(bc))d (ab)(cd). 阅读全文
posted @ 2013-04-22 17:07 heity 阅读(251) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1023该题就是求卡特兰数,只是处理的时候要用大数来处理,使用递推公式:h(n)=C(2n,n)/(n+1) (n=0,1,2,...)= A(2n,n)/(n+1)!改写我先求A(2n,n)然后除以(n+1)! 1 #include <cstdio> 2 #include <iostream> 3 #include <cstring> 4 5 using namespace std; 6 7 #define N 250 8 int a[N]; 9 10 void 阅读全文
posted @ 2013-04-22 16:09 heity 阅读(171) 评论(0) 推荐(0) 编辑
摘要: Train Problem ITime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 14413Accepted Submission(s): 5310Problem DescriptionAs the new term comes, the Ignatius Train Station is very busy nowadays. A lot of student want to get back to school by train(because 阅读全文
posted @ 2013-04-22 15:15 heity 阅读(131) 评论(0) 推荐(0) 编辑
摘要: Buy the TicketTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 3246Accepted Submission(s): 1350Problem DescriptionThe "Harry Potter and the Goblet of Fire" will be on show in the next few days. As a crazy fan of Harry Potter, you will go t 阅读全文
posted @ 2013-04-22 13:38 heity 阅读(135) 评论(0) 推荐(0) 编辑
摘要: 一开始想的时候吧那个搞错了,那个在同一层的时候对停留5S 1 #include <stdio.h> 2 #include <string.h> 3 4 int a[3005]; 5 6 int main() 7 { 8 int n; 9 while(scanf("%d",&n) && n)10 {11 int i;12 long sum = 0;13 memset(a,0,sizeof(a));14 for(i = 1; i <= n; i++)15 scanf("%d",&a... 阅读全文
posted @ 2013-04-22 10:26 heity 阅读(110) 评论(0) 推荐(0) 编辑
摘要: 定长覆盖时间限制:2000 ms | 内存限制:65535 KB难度:2描述问题很简单,在一条直线上,坐标从0开始到1000000;现在有n个石子在这条直线上(同一个位置可能有多个石子)那么用一个定长为m的杆子去覆盖,请问最多能覆盖多少个石子?输入输入有多组数据第一行有2个整数,n 和 m(n <= 50000,m <= 1000)第二行有n个整数代表每个石子的位置(所有的数小于50000)输出每种情况输出一个整数(最多能覆盖的石子数)样例输入3 20 0 15 20 1 2 4 5样例输出33首先求0--m的和值,然后进行加后减前,就是把后面一个的加上,把最前面的那个删除a[1- 阅读全文
posted @ 2013-04-20 17:27 heity 阅读(154) 评论(0) 推荐(0) 编辑