poj3073

  • 比赛状态堪忧,笑看自己找不着北..
  • 把心态放好吧- -
  • 反正窝从一开始就只是为了多学习才上道的
  • 至少已经从学习和智商上给窝带来了一些帮助
  • 智商带不动,好辛苦~~~~(>_<)~~~~ 
  • 说说这题吧…这题就是个 SB 题,考虑前 i 个字符能匹配的方案数,我们只需要考虑它后几位能否配上一组题目给出的字符即可,于是有
    dp[i]=j=1ndp[j](if.[j,i])
#include <cstdio>
#include <vector>
#include <string>
#include <cctype>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

const int MAX = 128 << 2;
int dp[MAX];
char rp[MAX >> 2][6] = 
{
    "4", "|3", "(", "|)", "3", "|=", "6", "#", "|",
    "_|", "|<", "|_", "|\\/|", "|\\|", "0", "|0", /*-P*/
    "(,)", "|?", "5", "7", "|_|", "\\/", "\\/\\/",
    "><", "-/", "2"
};

int main()
{
    char buffer[MAX];
    char s[MAX];
    while (cin >> buffer && buffer[0] != 'e')
    {
        s[0] = '\0';
        int len = strlen(buffer);
        for (int i = 0; i < len; ++i)
        {
            strcat(s, rp[buffer[i] - 'A']);
        }
        len = strlen(s);

        memset(dp, 0, sizeof(dp));
        for (int i = 0; i < len; ++i)
        {
            char ch = s[i + 1];
            s[i + 1] = '\0';
            for (int t = 0; t < 26; ++t)
            {
                if (strcmp(rp[t], s) == 0)
                {
                    ++dp[i];
                    break;
                }
            }

            for (int j = 1; j <= i; ++j)
            {
                for (int t = 0; t < 26; ++t)
                {
                    if (strcmp(rp[t], s + j) == 0)
                    {
                        dp[i] += dp[j - 1];
                    }
                }
            }
            s[i + 1] = ch;
        }
        cout << dp[len - 1] << endl;
    }
    return 0;
}
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值