| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1198 人关注过本帖
标题:Binomial theorem
只看楼主 加入收藏
ronaldowsy
Rank: 1
等 级:新手上路
帖 子:68
专家分:0
注 册:2008-10-20
收藏
 问题点数:0 回复次数:8 
Binomial theorem
Description

In mathematics, the binomial theorem is an important formula giving the expansion of powers of sums. Its simplest version states that
图片附件: 游客没有浏览图片的权限,请 登录注册


for any real or complex numbers x and y, and any nonnegative integer n. The binomial coefficient appearing in (1) may be defined in terms of the factorial function n!:
图片附件: 游客没有浏览图片的权限,请 登录注册


For example, here are the cases where 2 ≤ n ≤ 5:
图片附件: 游客没有浏览图片的权限,请 登录注册



History

This formula and the triangular arrangement of the binomial coefficients are often attributed to Blaise Pascal, who described them in the 17th century. But they were known to many mathematicians who preceded him: 4th century B.C. Greek mathematician Euclid, 3rd century B.C. Indian mathematician Pingala, 11th century Persian mathematician Omar Khayyám, and 13th century Chinese mathematician Yang Hui all derived similar results.

There have an other formula compute C(n,k):
C(n,k)=C(n-1,k-1)+C(n-1,k)

Your task is this formula above compute C(n,k).

Input

多组测试数据,每组提供n和k。以0,0结束。

Output

C(n,k)的结果。

Sample Input


2 1
3 1
4 4
10 6
0 0

Sample Output


2
3
1
210
搜索更多相关主题的帖子: theorem Binomial 
2008-11-13 17:04
ronaldowsy
Rank: 1
等 级:新手上路
帖 子:68
专家分:0
注 册:2008-10-20
收藏
得分:0 
怎么没人帮我啊?高手们啊!
2008-11-13 17:13
multiple1902
Rank: 8Rank: 8
等 级:贵宾
威 望:42
帖 子:4881
专家分:671
注 册:2007-2-9
收藏
得分:0 
你说你需要帮助了么
2008-11-13 22:35
ronaldowsy
Rank: 1
等 级:新手上路
帖 子:68
专家分:0
注 册:2008-10-20
收藏
得分:0 
麻烦高手们帮我搞定这个题好吗,谢谢
2008-11-14 11:59
geninsf009
Rank: 3Rank: 3
等 级:论坛游民
威 望:8
帖 子:613
专家分:95
注 册:2008-8-16
收藏
得分:0 
原来是二项式定理里的系数求解问题啊,
用递归吧.
2008-11-14 19:10
ronaldowsy
Rank: 1
等 级:新手上路
帖 子:68
专家分:0
注 册:2008-10-20
收藏
得分:0 
麻烦高手给出源代码,谢谢了
2008-11-15 00:39
ivapple
Rank: 1
等 级:新手上路
帖 子:46
专家分:0
注 册:2008-7-31
收藏
得分:0 
试试这个看行么
#include<stdio.h>
int main(){
    int n,k,i;
    double com;
    int c;
    while(scanf("%d%d",&n,&k)){
         if(n+k==0)
           break;
         com=1;
         if(k>n/2)
            k=n-k;
         for(i=1;i<=k;i++){
            com*=(n-i+1);
            com/=i;
         }
         c=int(com);
         printf("%d\n",c);
    }
    return 0;
}
2008-11-15 02:17
ronaldowsy
Rank: 1
等 级:新手上路
帖 子:68
专家分:0
注 册:2008-10-20
收藏
得分:0 
多谢了朋友!非常感谢
2008-11-15 12:33
wanchanfei
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2008-11-17
收藏
得分:0 
感谢拉
2008-11-17 16:57
快速回复:Binomial theorem
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015669 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved