洛谷2019 3月月赛 T2

题干

洛谷同款

T2?(看似比T1简单些)

二维前缀和嘛?【多简单 我天天拿二维前缀和水DP】

这是前缀和的预处理 2333 处理出来所有的情况 某个地方要加上mod再%mod

如果没有这一步 那么 70pts 然后附带5%的分值飞走。2333

然后...就A掉了

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
inline LL read () {
    LL res = 0 ;
    int f (1) ;
    char ch = getchar ();
    while (!isdigit(ch)) {
        if (ch == '-') f = -1 ;
        ch = getchar();
    }
    while (isdigit(ch)) res = (res << 1) + (res << 3) + (ch ^ 48),ch = getchar();
    return res * f ;
}
const LL Mod=19260817LL;
const LL N=1<<10;
LL q; LL yh[N][N],qzh[N][N];
inline void f() {
    yh[0][0]=1;
    for(register int i=1; i<=1000; i++)
        for(register int j=0; j<=i; j++) yh[i][j]=(yh[i-1][j]+yh[i-1][j-1])%Mod;
    for(register int i=1; i<=1000; i++)
        for(register int j=1; j<=1000; j++) qzh[i][j]=(qzh[i-1][j]+qzh[i][j-1]-qzh[i-1][j-1]+yh[i][j]+Mod)%Mod;
}
signed main() {
    f(); q=read();
    while(q--) {
        LL n=read(),m=read();
        cout << qzh [m] [n] << endl ;
    }
    return 0;
}

 

不存在十全十美的文章 如同不存在彻头彻尾的绝望
原文地址:https://www.cnblogs.com/qf-breeze/p/10462552.html