[计数 DP]Atcoder AGC001 E. BBQ Hard
来源:互联网 发布:怎样删除淘宝评价 编辑:程序博客网 时间:2024/06/07 02:39
答案是求
这就相当于从平面内的
把点放到平面上,DP就好了
#include <cstdio>#include <iostream>#include <algorithm>using namespace std;const int N=8010,P=1e9+7;int n,a[200010],b[200010],fac[N],inv[N];int f[N][N];inline int &F(int x,int y){ return f[x+2005][y+2005]; }inline void Pre(){ fac[0]=1; for(int i=1;i<=8000;i++) fac[i]=1LL*fac[i-1]*i%P; inv[1]=1; for(int i=2;i<=8000;i++) inv[i]=1LL*(P-P/i)*inv[P%i]%P; inv[0]=1; for(int i=1;i<=8000;i++) inv[i]=1LL*inv[i]*inv[i-1]%P;}inline int C(int x,int y){ return 1LL*fac[x]*inv[y]%P*inv[x-y]%P;}int main(){ freopen("1.in","r",stdin); freopen("1.out","w",stdout); scanf("%d",&n); Pre(); for(int i=1;i<=n;i++) scanf("%d%d",&a[i],&b[i]),F(-a[i],-b[i])++; for(int i=-2000;i<=2000;i++) for(int j=-2000;j<=2000;j++) F(i,j)=((long long)F(i,j)+F(i-1,j)+F(i,j-1))%P; int ans=0; for(int i=1;i<=n;i++) ans=((long long)ans+F(a[i],b[i])-C(a[i]+a[i]+b[i]+b[i],b[i]+b[i]))%P; ans=1LL*ans*(P+1>>1)%P; printf("%d\n",(ans+P)%P); return 0;}
阅读全文
0 0
- [计数 DP]Atcoder AGC001 E. BBQ Hard
- [agc001e]BBQ hard
- [构造] Atcoder AGC001 D. Arrays and Palindrome
- [AGC001E]BBQ Hard-组合数学
- codeforces 14E Camels (计数类dp)
- AtCoder 077E gururu
- Atcoder ARC 077 E
- Atcoder 080 E
- 【AtCoder】(AtCoder Grand Contest 004)E
- CodeForces 158E Phone Talks 树形dp+计数
- Codeforces 645E Intellectual Inquiry (dp不同子序列计数)
- 【AtCoder】(square869120Contest #3)E
- Atcoder Grand Contest 011E
- Atcoder Grand Contest 013E
- AtCoder Regular Contest 077 E
- AtCoder Regular Contest 077 E
- AtCoder Regular Contest 075 E
- AtCoder Grand Contest 018 E
- 关于学习react之前
- 第十四周LeetCode
- LOJ6001 「网络流 24 题
- [构造] Atcoder AGC001 D. Arrays and Palindrome
- 【Scikit-Learn 中文文档】无监督学习: 寻求数据表示
- [计数 DP]Atcoder AGC001 E. BBQ Hard
- javascript闭包
- 函数重载
- 最长递增子序列
- 《我的菜谱》-西红柿炒鸡蛋
- PAX
- HDU 3951 Coin Game(博弈水题)
- Linux 编译SSD Caffe目标检测代码
- 输入两个链表,找出它们的第一个公共结点