【z04】计算系数
2024-09-03 18:11:21
【题目链接】:http://noi.qz5z.com/viewtask.asp?id=z04
【题解】
用二项式定理可以写出下列通式
组合数可以用杨辉三角搞出来;
a的x次方直接乘就好了;指数也不大.
k可能会0;
所以c[0][0]=1不要忘了;不然会WA;
a很大。平方一下可能会爆int,注意开long long
【完整代码】
#include <cstdio>
#define LL long long
using namespace std;
const int MAXN = 1000+100;
const int MOD = 10007;
int c[MAXN][MAXN];
int a,b,k,n,m;
int main()
{
//freopen("F:\\rush.txt","r",stdin);
c[0][0] = 1;
for (int i = 1;i <= 1000;i++)
c[i][i] = c[i][0] = 1;
for (int i = 1;i <= 1000;i++)
for (int j = 1;j<= i-1;j++)
c[i][j] = (c[i-1][j]+c[i-1][j-1])%MOD;
scanf("%I64d%I64d%d%d%d",&a,&b,&k,&n,&m);
LL temp = 1;
for (int i = 1;i <= k-m;i++)
temp = (temp*a)%MOD;
LL temp1 = 1;
for (int i = 1;i <= m;i++)
temp1 = (temp1*b)%MOD;
temp = (temp*temp1)%MOD;
temp = (c[k][m]*temp)%MOD;
printf("%I64d\n",temp);
return 0;
}
最新文章
- 个人关于React的一些理解
- WPF,Silverlight与XAML读书笔记第四十六 - 外观效果之三皮肤与主题
- 《Continuous Delivery》 Notes 2: Configuration Management
- FingerGestures 屏蔽NGUI的方法
- 编译Ngnix遇到的问题,查看程序依赖的库文件
- Lazarus IDE的几个小技术
- 97、进入ScrollView根布局页面,直接跳到页面底部,不能显示顶部内容
- QTP10&;QTP11&;UFT11.5的安装和破解
- Foundation和UIKit框架图
- 【绿茶书情】:《SOHO小报》和《凤… - 绿茶的日志 - 网易博客
- Atom power-mode
- Cocos2d-x 3.0final手机游戏开发视频教程2014 - 自学编程 -(陆续更新中)
- zTree实现删除树节点
- KVM ->; 虚拟机磁盘管理_03
- 和我一起打造个简单搜索之ElasticSearch集群搭建
- 荔枝FM 字体文件 IconFontTextView
- koa2实现简单的图片上传
- [转帖学习] 使用阿里云证书 升级https
- win 7 浏览器被篡改小插曲
- pygame --- 可怜的小乌龟
热门文章
- 在kafka/config/目录下面有3个配置文件参数说明(producer.properties。consumer.properties。server.properties)
- Elasticsearch之源码分析(shard分片规则)
- Statement和ResultSet
- Spring模块作用
- 【Codeforces Round #456 (Div. 2) C】Perun, Ult!
- FZU 1921 栀子花开
- 使用PyCharm安装第三方库
- JavaScript学习总结(5)——Javascript面向(基于)对象编程
- 4. Spring Boot 过滤器、监听器
- 104.tcp多线程读写实现群聊