On the bulkhead law

Method separator is the last item in the order n is the number of columns in the separator so as to insert the k k + 1 number of columns is divided into blocks.

Is intended to simplify the problem of the number of columns n, each transition distance greater than or equal to k, m times jump, jump to last n number of programs.

We understand what method using a separator, is inserted into m blocks, to ensure that the length of each section is greater than or equal to k, then we can put all lengths are pushed to the left on the number of combinations becomes a problem.

And the subject is required (n-2- (m-1) * (k-1)) of the number of selected combinations of (m-2) problem.

Finally Lucas determination factor Theorem 2 can be determined parity.

#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll T,n,m,k;
inline ll read()
{
    ll x=0,ff=1;
    char ch=getchar();
    while(!isdigit(ch))
    {
        if(ch=='-') ff=-1;
        ch=getchar();
    }
    while(isdigit(ch))
    {
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    return x*ff;
}
int main()
{
    freopen("1.in","r",stdin);
    T=read();
    for(int i=1;i<=T;i++)
    {
        n=read();m=read();k=read();
        if(((m-2)&(n-2-(m-1)*(k-1)))==(m-2)) cout<<"Yes"<<endl;
        else                            cout<<"No"<<endl;
    }
    return 0;
} 

...

Guess you like

Origin www.cnblogs.com/gcfer/p/11496946.html
law