rt

rt
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int mod=1e9+7;
inline int rd(register int x=0,register char ch=getchar(),register int f=0){
    while(!isdigit(ch)) f=ch=='-',ch=getchar();
    while(isdigit(ch)) x=(x<<1)+(x<<3)+ch-48,ch=getchar();
    return f?-x:x;
}
ll mgml(ll a,ll b,ll ans=1){
    for(;b;b>>=1,a=a*a%mod) if(b&1) ans=ans*a%mod;
    return ans;
}
int n,m,k;
int main(){
    n=rd();m=rd();k=rd();
    if(n+m-1>k) return puts("0")&0;
    if(n==1){
        ll ans=1;
        for(int i=k;i>=k-m+1;--i) ans=ans*i%mod;
        return printf("%lld\n",ans)&0;
    }
    return 0;
}
/*//萎了。。。 
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int mod=1e9+7;
inline int rd(register int x=0,register char ch=getchar(),register int f=0){
    while(!isdigit(ch)) f=ch=='-',ch=getchar();
    while(isdigit(ch)) x=(x<<1)+(x<<3)+ch-48,ch=getchar();
    return f?-x:x;
}
ll mgml(ll a,ll b,ll ans=1){
    for(;b;b>>=1,a=a*a%mod) if(b&1) ans=ans*a%mod;
    return ans;
}
int n,m,k;
int dp[15][15][1050];
vector<int> state[15];
int main(){
    n=rd();m=rd();k=rd();
    if(n+m-1>k) return puts("0")&0;
    int U=1<<k;
    for(int i=0;i<U;++i){
        int cc=0;
        for(int j=i;j;j-=j&-j) cc++;
        state[cc].push_back(i);
    }
    for(int i=1;i<=n;++i) dp[i][0][0]=1;
    for(int i=1;i<=m;++i) dp[0][i][0]=1;
    int col1=rd();
    if(col1) dp[1][1][1<<col1-1]=1;
    else for(int i=1;i<=k;++i) dp[1][1][1<<i-1]=1;
    for(int i=1;i<=n;++i) for(int j=1;j<=m;++j){
        int col=rd();
        if(col){
            for(int s1=0,lim1=i==1?0:max(i-1,j);s1<(int)state[lim1].size();++s1)
                for(int s2=0,lim2=j==1?0:max(i,j-1);s2<(int)state[lim2].size();++s2){
                    int x=state[lim1][s1],y=state[lim2][s2];
                    if((x&(1<<col-1))==0&&(y&(1<<col-1))==0) (dp[i][j][x|y|(1<<col-1)]+=1LL*dp[i-1][j][x]*dp[i][j-1][y]%mod)%=mod;
                }
        }
        else{
            for(int s1=0,lim1=i==1?0:max(i-1,j);s1<(int)state[lim1].size();++s1)
                for(int s2=0,lim2=j==1?0:max(i,j-1);s2<(int)state[lim2].size();++s2){
                    int x=state[lim1][s1],y=state[lim2][s2];
                    //printf("->%d %d %d %d %d\n",i,j,x,y,(U-1)^(x|y));
                    for(int d=(U-1)^(x|y);d;d-=d&-d) (dp[i][j][x|y|(d&-d)]+=1LL*dp[i-1][j][x]*dp[i][j-1][y]%mod)%=mod;
                }
        }
    }
    //for(int i=1;i<=n;++i) for(int j=1;j<=m;++j) for(int d=0;d<U;++d) printf("i:%d j:%d d:%d dp:%d\n",i,j,d,dp[i][j][d]);
    int ans=0;
    for(int i=0;i<U;++i) (ans+=dp[n][m][i])%=mod;
    printf("%d\n",(ans%mod+mod)%mod);
    return 0;
}*/
T3
上一篇:UVA679 - Dropping Balls 题解


下一篇:树莓派4B的初步认识