bzoj3505 组合数
来源:互联网 发布:淘宝分期付款额度 编辑:程序博客网 时间:2024/05/16 07:36
http://www.lydsy.com/JudgeOnline/problem.php?id=3505
这道题斜边一开始想成o(n^2m^2)的了……实际上是一道很水的题.注意1000*1000的范围,组合数最好递推.
/************************************************************** Problem: 3505 User: MaxMercer Language: C++ Result: Accepted Time:516 ms Memory:32228 kb****************************************************************/#include<stdio.h>#include<algorithm>typedef long long dnt;dnt ans,c[1005005][4],tmp;int gcd(int a,int b){return b==0?a:gcd(b,a%b);}int n,m;void cc(){ c[0][0]=1; for(register int i=1;i<=n*m;i++){ c[i][0]=1; for(int j=1;j<=3;j++) c[i][j]=c[i-1][j-1]+c[i-1][j]; }}int main(){ scanf("%d%d",&n,&m); n++,m++; cc(); ans=c[n*m][3]; ans-=c[m][3]*n; ans-=c[n][3]*m; for(int i=1;i<n;i++) for(int j=1;j<m;j++){ tmp=gcd(i,j)+1; if(tmp>2) ans-=(tmp-2)*2*(n-i)*(m-j); } printf("%lld",ans);}
阅读全文
0 0
- bzoj3505 组合数
- 【bzoj3505】【CQOI2014】【数三角形】【组合数学】
- 组合数学+gcd BZOJ3505 [Cqoi2014]数三角形
- 【组合】BZOJ3505(Cqoi2014)[数三角形]题解
- [BZOJ3505][Cqoi2014]数三角形(组合数学+gcd)
- [Bzoj3505][Cqoi2014]数三角形
- bzoj3505 [Cqoi2014]数三角形
- bzoj3505: [Cqoi2014]数三角形
- bzoj3505 [Cqoi2014]数三角形
- 【CQOI2014】【BZOJ3505】数三角形
- bzoj3505【CQOI2014】数三角形
- bzoj3505: [Cqoi2014]数三角形
- 【bzoj3505】[Cqoi2014]数三角形
- BZOJ3505[数三角形]
- bzoj3505 [Cqoi2014]数三角形
- bzoj3505 [Cqoi2014]数三角形
- BZOJ3505 [Cqoi2014]数三角形
- 【bzoj3505】 CQOI2014数三角形 数学
- OpenGL ES Android 基础(一)
- Android 开发ListView学习总结
- typeof的缺点以及解决方式
- unity学习日记:关于协同程序Coroutine
- PAT (Advanced Level) Practise 1081 Rational Sum(20)
- bzoj3505 组合数
- geckodriver下载 -- Selenium Firefox 驱动
- eclipse-tomcatplugin部署maven项目方式五
- 天啦噜:测试环境OK,发布到公网跑不了?!!!
- JPMML解析Random Forest模型并使用其预测分析
- webservice学习笔记
- Android 开发 自定义Dialog
- 36 《魔鬼数学 : 大数据时代,数学思维的力量》 -豆瓣评分8.3
- Android manifest <activity> screenOrientation && windowSoftInputMode