恒邪

2014年4月5日 #

[ACM] hdu 2067 小兔的棋盘(卡特兰数Catalan)

摘要: 小兔的棋盘Time Limit: 1000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 5814Accepted Submission(s): 3186Problem Description小兔的叔叔从外面旅游回来给她带来了一个礼物,小兔高兴地跑回自己的房间,拆开一看是一个棋盘,小兔有所失望。不过没过几天发现了棋盘的好玩之处。从起点(0,0)走到终点(n,n)的最短路径数是C(2n,n),现在小兔又想如果不穿越对角线(但可接触对角线上的格点),这样的路径数有多少?小兔想了很 阅读全文

posted @ 2014-04-05 20:57 恒邪 阅读(742) 评论(0) 推荐(0) 编辑

[ACM] poj 2249 Binomial Showdown (排列组合公式优化)

摘要: DescriptionIn how many ways can you choose k elements out of n elements, not taking order into account?Write a program to compute this number. InputThe input will contain one or more test cases. Each test case consists of one line containing two integers n (n>=1) and k (0using namespace std;const 阅读全文

posted @ 2014-04-05 20:02 恒邪 阅读(191) 评论(0) 推荐(0) 编辑

队列逆置

摘要: 思路:用一个栈起到过渡的作用。先将队列中的元素放入栈中,然后初始化队列,再将元素从栈中取出放到初始化的队列中。代码:#include #include #include using namespace std;const int maxn=10;typedef struct{ char data[maxn]; int front,rear;}Queue;typedef struct{ char data[maxn]; int top;}Stack;void Reverse(Queue &q,Stack &s){ s.top=-1; while(q.front... 阅读全文

posted @ 2014-04-05 14:34 恒邪 阅读(203) 评论(0) 推荐(0) 编辑

[ACM] 括号匹配问题(栈的使用)

摘要: 括号配对问题时间限制:3000 ms | 内存限制:65535 KB难度:3描述 现在,有一行括号序列,请你检查这行括号是否配对。输入 第一行输入一个数N(0#include #include using namespace std;char e[10000];bool match(stack s,char e[],int n){ for(int i=0;i>t; while(t--) { cin>>e; int len=strlen(e); stacks; if(match(s,e,len)) c... 阅读全文

posted @ 2014-04-05 13:18 恒邪 阅读(181) 评论(0) 推荐(0) 编辑

导航