uva 825

这个......小学生就会的  坑在输入输出了  两个数之间可能不止一个空格....wa了好几遍啊

#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;
int g[1130][1130],dp[1130][1130];
char str[1130];
int main()
{
    int T,W,N;
    scanf("%d",&T);
    while(T--)
    {
        memset(g, 0, sizeof(g));
        memset(dp, 0, sizeof(dp));
        scanf("%d%d",&W,&N);
        getchar();
        for (int i = 1; i <= W; i++)
        {
            gets(str);
            bool flag = 0;
            int j = 0;
            while (str[j])
            {
                if (str[j] >= '0' && str[j] <= '9')
                {
                    int ans = 0;
                    while (str[j] >= '0' && str[j] <= '9')
                        ans = ans * 10 + str[j++] - '0';
                    if (flag)
                        g[i][ans] = 1;
                    flag = 1;
                }
                else j++;
            }
        }
        dp[0][1] = 1;
        for(int i = 1; i <= W; i++)
            for(int j = 1; j <= N; j++)
                if(!g[i][j])
                    dp[i][j] += dp[i-1][j]+dp[i][j-1];
        printf("%d\n",dp[W][N]);
        if(T)
            puts("");
    }
    return 0;
}


转载于:https://www.cnblogs.com/avema/p/3774345.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值