博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
zoj 3494:BCD Code
阅读量:5250 次
发布时间:2019-06-14

本文共 2727 字,大约阅读时间需要 9 分钟。

Description

Binary-coded decimal (BCD) is an encoding for decimal numbers in which each digit is represented by its own binary sequence. To encode a decimal number using the common BCD encoding, each decimal digit is stored in a 4-bit nibble:

Decimal:    0     1     2     3     4     5     6     7     8     9BCD:     0000  0001  0010  0011  0100  0101  0110  0111  1000  1001

Thus, the BCD encoding for the number 127 would be:

0001 0010 0111

We are going to transfer all the integers from A to B, both inclusive, with BCD codes. But we find that some continuous bits, named forbidden code, may lead to errors. If the encoding of some integer contains these forbidden codes, the integer can not be transferred correctly. Now we need your help to calculate how many integers can be transferred correctly.

 

Input

 

There are multiple test cases. The first line of input is an integer T ≈ 100 indicating the number of test cases.

The first line of each test case contains one integer N, the number of forbidden codes ( 0 ≤ N ≤ 100). Then N lines follow, each of which contains a 0-1 string whose length is no more than 20. The next line contains two positive integers A and B. Neither A or B contains leading zeros and 0 < A ≤ B < 10200.

 

Output

 

For each test case, output the number of integers between A and B whose codes do not contain any of the N forbidden codes in their BCD codes. For the result may be very large, you just need to output it mod 1000000009.

 

Sample Input

 

 

31001 101001 100111111 100

 

 

Sample Output

 

 

3998 还是太怂了啊……终究还是只能照着CZL的标程写出来……gg啦 先预处理出AC自动机上某个节点在它后面加上[0...9]这些数字之后会到达哪一个节点或者不能添加该数字,然后就是普通数位dp了
#include
#include
#include
#include
using namespace std;int read_p,read_ca;inline int read(){ read_p=0;read_ca=getchar(); while(read_ca<'0'||read_ca>'9') read_ca=getchar(); while(read_ca>='0'&&read_ca<='9') read_p=read_p*10+read_ca-48,read_ca=getchar(); return read_p;}const int LO=2,MOD=1000000009;inline void M(int &ans){ if (ans>=MOD) ans-=MOD;}struct tree{ int f; bool w; int t[LO],v[LO];}t[2001];char s[10001],n,m,tt;bool us[2001];int map[2001][10],f[2001][202],ti[2001][202];int num=0;queue
q;inline void in(){ int m=strlen(s),p=0; for (int i=0;i
=0;k--){ p=t[p].v[((1<
0]; if (t[p].w) break; } if (t[p].w) map[i][j]=-1;else map[i][j]=p; }}inline void FI(){ for (int i=0;i<=num;i++) t[i].w=t[i].f=us[i]=0; for (int i=0;i<=num;i++) for (int j=0;j
=0;i--) if (s[i]!='9') break; if (i>=0){ s[i]++;for (i++;i
View Code

 

转载于:https://www.cnblogs.com/Enceladus/p/5334885.html

你可能感兴趣的文章
程序的静态链接,动态链接和装载 (补充)
查看>>
关于本博客说明
查看>>
线程androidAndroid ConditionVariable的用法
查看>>
stap-prep 需要安装那些内核符号
查看>>
转载:ASP.NET Core 在 JSON 文件中配置依赖注入
查看>>
socket初识
查看>>
磁盘测试工具
查看>>
代码变量、函数命名神奇网站
查看>>
redis cli命令
查看>>
Problem B: 占点游戏
查看>>
python常用模块之sys, os, random
查看>>
HDU 2548 A strange lift
查看>>
Linux服务器在外地,如何用eclipse连接hdfs
查看>>
react双组件传值和传参
查看>>
[Kaggle] Sentiment Analysis on Movie Reviews
查看>>
价值观
查看>>
mongodb命令----批量更改文档字段名
查看>>
CentOS 简单命令
查看>>
使用&nbsp;SharedPreferences 分类: Andro...
查看>>
TLA+(待续...)
查看>>