码迷,mamicode.com
首页 > 其他好文 > 详细

小a和uim之大逃离

时间:2019-04-12 00:40:28      阅读:152      评论:0      收藏:0      [点我收藏+]

标签:ack   using   i++   tar   register   lan   for   utc   push   

题目传送门

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define re register
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define P pair<int,int>
const int N=1e9;
const int mod=1e9+7;
void read(int &a)
{
    a=0;
    int d=1;
    char ch;
    while(ch=getchar(),ch>9||ch<0)
        if(ch==-)
            d=-1;
    a=ch-0;
    while(ch=getchar(),ch>=0&&ch<=9)
        a=a*10+ch-0;
    a*=d;
}
void write(int x)
{
    if(x<0)
        putchar(45),x=-x;
    if(x>9)
        write(x/10);
    putchar(x%10+0);
}
int f[805][805][20][2],a[805][805];
int main()
{
    int n,m,k;
    read(n);
    read(m);
    read(k);
    k++;
    for(re int i=1;i<=n;i++)
        for(re int j=1;j<=m;j++)
            read(a[i][j]),f[i][j][a[i][j]%k][0]=1;
    for(re int i=1;i<=n;i++)
        for(re int j=1;j<=m;j++)
            for(re int h=0;h<=k;h++)
            {
                f[i][j][h][0]=(f[i][j][h][0]+f[i-1][j][(h-a[i][j]+k)%k][1])%mod;
                f[i][j][h][0]=(f[i][j][h][0]+f[i][j-1][(h-a[i][j]+k)%k][1])%mod;
                f[i][j][h][1]=(f[i][j][h][1]+f[i-1][j][(h+a[i][j])%k][0])%mod;
                f[i][j][h][1]=(f[i][j][h][1]+f[i][j-1][(h+a[i][j])%k][0])%mod;
            }
    ll ans=0;
    for(re int i=1;i<=n;i++)
        for(re int j=1;j<=m;j++)
            ans=(ans+f[i][j][0][1])%mod;
    printf("%lld",ans);
    return 0;
}

 

小a和uim之大逃离

标签:ack   using   i++   tar   register   lan   for   utc   push   

原文地址:https://www.cnblogs.com/acm1ruoji/p/10693501.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!