垃圾桶--

异或规律:

x\ or\ y = x+y-(x\ and\ y)

AND, OR and square sum - 洛谷


Johnson 全源最短路

组合数板子

#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int mod=1e9+7;
const int N=1e5+10;
ll f[N],invf[N];
ll pows(ll a,ll n)
{
    ll ans=1;
    while(n)
    {
        if(n&1)
        {
            ans=ans*a%mod;
        }
        a=a*a%mod;
        n>>=1;
    }
    return ans;
}
void init()
{
    f[1]=1;
    invf[1]=pows(f[1],mod-2);
    for(int i=2; i<N; i++)
    {
        f[i]=f[i-1]*i%mod;
        invf[i]=pows(f[i],mod-2);
    }
}
ll c(ll a,ll b)
{
    return f[a]*invf[a-b]%mod*invf[b]%mod;
}
int main()
{
    init();
    int n;
    cin>>n;
    while(n--)
    {
        ll a,b;
        cin>>a>>b;
        if(a==b)
        {
            cout<<1<<endl;
        }
        else
            cout<<c(a,b)<<endl;
    }
    return 0;
}

SG函数及SG定理详解+证明

线段树模板_c++ 线段树模板-CSDN博客

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值