博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
HDOJ 5411 CRB and Puzzle 矩阵高速幂
阅读量:7104 次
发布时间:2019-06-28

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

直接构造矩阵,最上面一行加一排1.高速幂计算矩阵的m次方,统计第一行的和

CRB and Puzzle

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 133    Accepted Submission(s): 63


Problem Description
CRB is now playing Jigsaw Puzzle.
There are 
N kinds of pieces with infinite supply.
He can assemble one piece to the right side of the previously assembled one.
For each kind of pieces, only restricted kinds can be assembled with.
How many different patterns he can assemble with at most 
M pieces?

(Two patterns P and Q are considered different if their lengths are different or there exists an integer j such that j-th piece of P is different from corresponding piece of Q.)

 

Input
There are multiple test cases. The first line of input contains an integer 
T, indicating the number of test cases. For each test case:
The first line contains two integers 
N
M denoting the number of kinds of pieces and the maximum number of moves.
Then 
N lines follow. 
i-th line is described as following format.
a1 a2 ... ak
Here 
k is the number of kinds which can be assembled to the right of the 
i-th kind. Next 
k integers represent each of them.
1 ≤ 
T ≤ 20
1 ≤ 
N ≤ 50
1 ≤ 
M ≤ 
105
0 ≤ 
k ≤ 
N
1 ≤ 
a1 < 
a2 < … < 
ak ≤ N
 

Output
For each test case, output a single integer - number of different patterns modulo 2015.
 

Sample Input
 
1 3 2 1 2 1 3 0
 

Sample Output
 
6
Hint
possible patterns are ∅, 1, 2, 3, 1→2, 2→3
 

Author
KUT(DPRK)
 

Source
 

/* ***********************************************Author        :CKbossCreated Time  :2015年08月20日 星期四 23时25分19秒File Name     :HDOJ5411.cpp************************************************ */#include 
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;const int mod=2015;int n,m;struct Matrix{ int m[60][60]; Matrix() { memset(m,0,sizeof(m)); } void getE() { for(int i=0;i

转载地址:http://iuchl.baihongyu.com/

你可能感兴趣的文章
查询存储过程所需参数
查看>>
HTML5 Web app开发工具Kendo UI Web教程:如何配置Kendo UI Calendar
查看>>
vue Element动态设置el-menu导航当前选中项
查看>>
session的使用
查看>>
Centos6.8通过yum安装mysql5.7
查看>>
Asp.net 4.0,首次请求目录下的文件时响应很慢
查看>>
hdu-------(1848)Fibonacci again and again(sg函数版的尼姆博弈)
查看>>
GridView编辑删除操作
查看>>
iOS程序的启动图片图标规范
查看>>
动画 -- 按钮 -- 左右晃动
查看>>
mysql+ssh整合样例,附源代码下载
查看>>
WWF3XOML方式创建和启动工作流 <第十篇>
查看>>
IE6 — 你若安好,便是晴天霹雳 [ 乱弹 ]
查看>>
组合数学 - 母函数的运用 --- 模板题
查看>>
检测MYSQL不同步发邮件通知的脚本
查看>>
Struts2学习笔记1
查看>>
python的ftp上传和下载
查看>>
ASP.NET MVC 中的路由
查看>>
微信公众平台帐号通过昵称无法搜索到怎么办
查看>>
Oracle笔记 六、PL/SQL简单语句块、变量定义
查看>>