题意:

1≤T≤200

● 1≤length(N)≤100

思路:

设f[i,j,k,l]为第i位为j,前i位是否贴上限(0/1),递减或递增(0/1)方案数

g[i,j,k]为不到n位,第i位为j,递减或递增方案数

 const mo=;
var f:array[..,..,..,..]of longint;
g:array[..,..,..]of longint;
a:array[..]of longint;
v,n,i,j,k,l,jj,kk,ans,cas,ll:longint;
ch:string; begin readln(cas);
for v:= to cas do
begin
readln(ch);
n:=length(ch);
for i:= to n do a[i]:=;
for i:= to n do a[i]:=ord(ch[i])-ord('');
for i:= to n do
for j:= to do
for k:= to do
for l:= to do f[i,j,k,l]:=;
for i:= to a[]- do f[,i,,]:=;
f[,a[],,]:=;
for i:= to n do
for j:= to do
for k:= to do
for l:= to do
for jj:= to do
begin
if k= then kk:=;
if (k=)and(jj<a[i]) then kk:=;
if (k=)and(jj=a[i]) then kk:=;
if (k=)and(jj>a[i]) then break;
for ll:=l to do
begin
if (ll=)and(j<jj) then continue;
if (ll=)and(j>jj) then continue;
if (ll<>l)and(j=jj) then continue;
f[i,jj,kk,ll]:=(f[i,jj,kk,ll]+f[i-,j,k,l]) mod mo;
end;
end;
for i:= to n- do
for j:= to do
for k:= to do g[i,j,k]:=;
for i:= to do g[,i,]:=;
for i:= to n- do
for j:= to do
for k:= to do
for jj:= to do
for kk:=k to do
begin
if (kk=)and(j<jj) then continue;
if (kk=)and(j>jj) then continue;
if (k<>kk)and(j=jj) then continue;
g[i,jj,kk]:=(g[i,jj,kk]+g[i-,j,k]) mod mo;
end;
ans:=;
for j:= to do
for k:= to do
for l:= to do ans:=(ans+f[n,j,k,l]) mod mo;
for i:= to n- do
for j:= to do
for k:= to do ans:=(ans+g[i,j,k]) mod mo;
writeln(ans);
end; end.

最新文章

  1. C语言运算符优先级 详细列表
  2. angularJ之$filter过滤器
  3. C#多线程之旅(1)——介绍和基本概念
  4. HoverTree开发日志之验证码
  5. Linux双机信任,适用统一安装
  6. FIREFOX A tool for easily making HTTP requests (GET/PUT/POST/DELETE)
  7. [转](四)unity4.6Ugui中文教程文档-------概要-UGUI Visual Components
  8. Tarjan算法求有向图的强连通分量
  9. sql中with as的用法练习
  10. webpack教程(六)——分离组件代码
  11. MySQL系列:高可用架构之MHA
  12. 新概念英语(1-111)The most expensive model
  13. JS的进阶技巧
  14. Git .gitignore文件说明
  15. java 一次CPU占用过高问题的排查及解决
  16. A new session could not be created. (Original error: Requested a new session but one was in progress) (WARNING: The server did not provide any stacktrace information)
  17. elasticsearch 安装 windows linux macOS
  18. cl 命令行配置
  19. Math.round(),Math.ceil(),Math.floor()
  20. springboot整合druid数据库连接池并开启监控

热门文章

  1. 详解Android Activity生命周期
  2. (转载)Sql注入的分类:数字型+字符型
  3. 简单探讨弹性布局flex
  4. RequireJS 上手使用
  5. 程序员段子:世界上最大的同性交友平台github
  6. mfc 菜单
  7. vue 常用功能和命令
  8. JavaSE-10 多态
  9. jQuery动态移除和绑定事件
  10. css + 和 ~的区别