poj2249Binomial Showdown

2024-02-09 17:18
文章标签 showdown poj2249binomial

本文主要是介绍poj2249Binomial Showdown,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

要做这道题首先要懂排列组合。其中如果m>n/2,可以把m=n-m。因为Cm(上)n(下)等于C(n-m)(上)n(下);
以防数据溢出  边乘边除。
#include <stdio.h>
int main()
{long long sum1,sum2;int n,m,i,j;while(scanf("%d %d",&n,&m)!=EOF&&(n||m)){sum1=sum2=1;if(m>n/2)m=n-m;for(i=n,j=m;i>n-m;i--,j--){sum1=sum1*i;if(sum1%j==0)sum1=sum1/j;else if(sum1%sum2==0&&sum2!=1)sum1=sum1/sum2,sum2=j;elsesum2=sum2*j;}printf("%lld\n",sum1/sum2);}return 0;
}

这篇关于poj2249Binomial Showdown的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/694839

相关文章

using showdown js with openAi streaming response

题意:"使用 Showdown.js 处理 OpenAI 流式响应" 问题背景: I tried using showdownjs to translate streamed markdown from OpenAi to HTML "我尝试使用 Showdown.js 将来自 OpenAI 的流式 Markdown 转换为 HTML" I changed the code g

@synchronized, NSLock, pthread, OSSpinLock showdown, done right

http://perpendiculo.us/2009/09/synchronized-nslock-pthread-osspinlock-showdown-done-right/ Somewhere out there on the internet, there’s a “showdown” between @synchronized, NSLock, pthread mute