JZOJ5358【NOIP2017提高A组模拟9.12】BBQ
来源:互联网 发布:apache ftpclient加密 编辑:程序博客网 时间:2024/06/06 14:09
题目
分析
发现,
我们可以想办法将i、j分开,从(0,0)走最短路到(ai+aj,bi+bj)其实就相当于从(-ai,-bi)走最短路到(aj,bj),
那么,在坐标系上,计算出所有(-ai,-bi),到所有(ai,bi)的值,
但是对于i—>i会被算上,减去这种情况;
又因为i—>j会算两次,再除一个2,就是答案。
#include <cmath>#include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>#include <algorithm>#include <queue>#include <map>const int maxlongint=2147483647;const long long mo=1e9+7;const int N=4010;const int M=2002;using namespace std;long long f[N][N],jc[N*2],n,m,ans,ny[N*2],bz[N][N];long long mi(long long x,long long y){ long long sum=1; while(y) { if(y&1) sum=sum*x%mo; x=x*x%mo; y>>=1; } return sum;}long long C(int m,int n){ return jc[m]*ny[n]%mo*ny[m-n]%mo;}int main(){ jc[0]=ny[0]=1; for(int i=1;i<=N*2-1;i++) jc[i]=jc[i-1]*i%mo,ny[i]=mi(jc[i],mo-2); scanf("%lld",&n); ans=0; for(int i=1,x,y;i<=n;i++) { scanf("%d%d",&x,&y); bz[M+x][M+y]++; f[M-x][M-y]++; ans=(ans-C(x+y+x+y,x+x)+mo)%mo; } for(int i=1;i<=N-1;i++) for(int j=1;j<=N-1;j++) f[i][j]=(f[i][j]+f[i][j-1]+f[i-1][j])%mo,ans=(ans+bz[i][j]*f[i][j]%mo)%mo; printf("%lld",ans*ny[2]%mo);}
阅读全文
0 0
- JZOJ5358. 【NOIP2017提高A组模拟9.12】BBQ
- [JZOJ5358]【NOIP2017提高A组模拟9.12】BBQ
- JZOJ5358. 【NOIP2017提高A组模拟9.12】BBQ
- JZOJ5358【NOIP2017提高A组模拟9.12】BBQ
- 【jzoj5358】【NOIP2017提高A组模拟9.12】【BBQ】
- 【JZOJ 5358】【NOIP2017提高A组模拟9.12】BBQ
- 5358. 【NOIP2017提高A组模拟9.12】BBQ
- 【jzoj5360】【NOIP2017提高A组模拟9.12】【Shorten Diameter】
- 【jzoj5359】【NOIP2017提高A组模拟9.12】【Arrays and Palindrome】
- JZOJ5360. 【NOIP2017提高A组模拟9.12】Shorten Diameter
- 【NOIP2017提高A组模拟9.12】Shorten Diameter
- A【NOIP2017提高组模拟12.18】
- 【JZOJ4928】【NOIP2017提高组模拟12.18】A
- 【NOIP2017提高组模拟12.18】A
- 【JZOJ4928】【NOIP2017提高组模拟12.18】A
- 【NOIP2017提高A组模拟7.7】图
- 【NOIP2017提高A组模拟7.13】abcd
- 区间【NOIP2017提高A组模拟7.10】
- mongodb安装及常用命令
- ScheduledExecutorService定时周期执行指定的任务
- FastDFS架构介绍
- Hbase的java API遇到的问题以及解决方法
- date_format(a.dataTime, '%Y-%m-%d') date
- JZOJ5358【NOIP2017提高A组模拟9.12】BBQ
- 短实习---Java接口、关键字(基础知识)
- upD79F8513A(NEC)或upD78F0511A(NEC)之初始化外部8M晶振做系统时钟
- 定时任务实现Timer, TimeTask, ScheduledExecutorService及Spring定时器
- Easy2D游戏引擎 1st —— 课前预习,准备Easy2D引擎
- poj3468 A Simple Problem with Integers(线段树+区间更新+非完全替换)模板
- 172. Factorial Trailing Zeroes
- 分布式系统一致性、可用性
- php简单分页