HDU6333 Problem B. Harvest of Apples 莫队算法+乘法逆元

HDU6333 Problem B. Harvest of Apples

莫队算法 求(0,n)~(m,n)组合数之和

#include 
using namespace std;
const int MAX=1e5+5;
const int BLOCK=(int)sqrt(1e5);
const long long MOD=1e9+7;
long long fact[MAX],inv[MAX];
struct ask
{
    int n,m,id,block;
    long long ans;
}a[MAX];
bool cmp1(ask b,ask c)
{
    return b.block==c.block?b.ml)
        {
            sum=(2*sum-fact[l]*inv[r]%MOD*inv[l-r]%MOD+MOD)%MOD;
            l++;
        }
        while(Lr)
        {
            sum=(sum+fact[l]*inv[r+1]%MOD*inv[l-r-1]%MOD)%MOD;
            r++;
        }
        while(R

 

你可能感兴趣的:(莫队算法,数学)