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;
}
poj3073的更多相关文章
- django 操作数据库--orm(object relation mapping)---models
思想 django为使用一种新的方式,即:关系对象映射(Object Relational Mapping,简称ORM). PHP:activerecord Java:Hibernate C#:Ent ...
随机推荐
- OpenCV 学习笔记03 drawContours函数
opencv-python 4.0.1 轮廓的绘制或填充. cv2.drawContours(image, contours, contourIdx, color[, thickness[, li ...
- yum install mysql56
官方有写: http://dev.mysql.com/doc/mysql-repo-excerpt/5.6/en/linux-installation-yum-repo.html yum update ...
- Linux下实现脚本监测特定进程占用内存情况
Linux系统下,我们可以利用以下命令来获取特定进程的运行情况: cat /proc/$PID/status 其中PID是具体的进程号,这个命令打印出/proc/特定进程/status文件的内容,信息 ...
- mvc 缓存页面 减轻服务器压力
方法: using System; using System.Collections.Generic; using System.Linq; using System.Web; using Syste ...
- GDI+绘制渐变色
例1: void CTextDlg::OnPaint(){Graphics graphics(this->m_hWnd); LinearGradientBrush linGrBrush( Poi ...
- Groovy 学习手册(3)
五. Groovy 的设计模式 设计模式是一种非常好的方式,可以使你的代码变得实用,可读又具有扩展性.跟 Java 相比,在 Groovy 里使用设计模式使代码更加简洁和容易. 1. 策略模式 设想一 ...
- php超时时间说明
一,http请求超时时间 可能出现的场景: 1,curl进程运行了一个世纪还木结束,curl的时候设置了超时时间 --connect-timeout 1000 2,operation timed ou ...
- java播放wav文件
import java.io.File; import java.io.IOException; import javax.sound.sampled.AudioFormat; import java ...
- apiDoc自动生成api文档
在自定生成api文档方面以前都是使用swagger.json结合swagger工具来生成文档,偶然发现了apidoc这个生成api的工具,发现使用起来比swagger更加简单,下面整理一下使用过程: ...
- Google Mesa概览
Google Mesa的文章:https://research.google.com/pubs/pub42851.html https://gigaom.com/2014/08/07/google- ...