star

搜索

RSS

RSS Link

计数器

133371
乱代码之右三角
N皇后问题

卡特兰数

Star posted @ 2010年8月08日 23:29 in C语言 with tags c 数学 递归式 高精度 排列组合 , 2008 阅读

$$C(0) = 1$$

$$C(n) = \frac{C(n-1)(4n-2)}{n+1} (n>0)$$

#include <stdio.h>
int C[101][101], len[101];

int main(void)
{
	int i, j, r, t, l;
	C[0][0] = 1;
	len[0]  = 1;
	l       = 1;        //长度
	
	for(i = 1; i <= 100; ++i)
	{
		for(j = 0; j < l; ++j)        //乘法
			C[i][j] = C[i-1][j] * (4*i-2);
		for(r=j = 0; j < l; ++j)
		{
			t       = C[i][j] + r;
			C[i][j] = t % 10;
			r       = t / 10;
		}
		while(r)
			C[i][l++] = r % 10, r /= 10;
		for(j = l-1, r = 0; j >= 0; --j)        //除法
		{
			t       = r*10 + C[i][j];
			C[i][j] = t / (i+1);
			r       = t % (i+1);
		}
		while(!C[i][l-1])
			--l;
		len[i] = l;
	}
			
	for(i = 1; i <= 100; ++i)
	{
		printf("%d:", i);
		for(j = len[i]-1; j >= 0; --j)
			printf("%d", C[i][j]);
		putchar(10);
	}
	
	return 0;
}
Tyler Hamilton 说:
2020年3月20日 22:58

I really benefit from locating a site that gives you good information since I like finding out new things. I wanted to convey that I discovered the content on your web page has been quite entertaining and that I learnt something new. An excellent web site and I will return again for additional fantastic content… china virtual phone number

Tyler Hamilton 说:
2020年4月18日 05:14

Thanks for writing such a good article, I stumbled onto your blog and read a few post. I like your style of writing... 온라인카지노

Tyler Hamilton 说:
2020年4月25日 00:55

Cool you inscribe, the info is really salubrious further fascinating, I'll give you a connect to my scene.  메이저사이트

Tyler Hamilton 说:
2020年4月27日 02:34

This is very appealing, however , it is very important that will mouse click on the connection: 남성확대

Tyler Hamilton 说:
2020年5月08日 00:35

You ought to basically fantastic not to mention solid advice, which means notice: sexybaccarat

호빠, 호스트바, 호빠 구인, 선수하 说:
2020年7月06日 02:47

On this page, you'll see my profile, please read this information.    wood garage doors centereach ny

호빠, 호스트바, 호빠 구인, 선수하 说:
2020年7月08日 22:25

On this page, you'll see my profile, please read this information.    best seo sydney

Anonymous 说:
2020年7月11日 01:41

Cool you inscribe, the info is really salubrious further fascinating, I'll give you a connect to my scene.  grind

Anonymous 说:
2020年7月18日 05:33

Find the best essays on     is my friend's profile page. smm panel

먹튀검증업체 说:
2020年8月17日 02:34

This is important, though it's necessary to help you head over to it weblink:

dark web market link 说:
2020年12月18日 19:19

Acknowledges for penmanship such a worthy column, I stumbled beside your blog besides predict a handful advise. I want your tone of manuscript...

AP Board Jr Inter Mo 说:
2021年10月26日 14:02

AP Inter Model Paper 2022 (BIEAP) will conduct the Intermediate 1st Year Examination in the months of March and April for the Government of Andhra Pradesh's Public Examinations 2022. Students To visit the official webpage, AP Board Jr Inter Model Paper 2022 check and download the AP Intermediate 1st Year Exam Question Paper 2022. Intermediate timetable for AP Every year, a large number of students study in the Andhra Pradesh Board Intermediate Education, as announced on the official website. Every year, fresh students apply for admission to the BIEAP.


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter