码迷,mamicode.com
首页 > 其他好文 > 详细

HDU 多校1.7

时间:2017-07-25 13:28:06      阅读:140      评论:0      收藏:0      [点我收藏+]

标签:mit   hdu   multiple   perm   time   ram   out   ssi   java   

Function

Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 0    Accepted Submission(s): 0


Problem Description
You are given a permutation a技术分享 from 0技术分享 to n−1技术分享 and a permutation b技术分享 from 0技术分享 to m−1技术分享 .

Define that the domain of function f技术分享 is the set of integers from 0技术分享 to n−1技术分享 , and the range of it is the set of integers from 0技术分享 to m−1技术分享 .

Please calculate the quantity of different functions f技术分享 satisfying that f(i)=b技术分享f(a技术分享i技术分享)技术分享技术分享 for each i技术分享 from 0技术分享 to n−1技术分享 .

Two functions are different if and only if there exists at least one integer from 0技术分享 to n−1技术分享 mapped into different integers in these two functions.

The answer may be too large, so please output it in modulo 10技术分享9技术分享+7技术分享 .
 

 

Input
The input contains multiple test cases.

For each case:

The first line contains two numbers n,技术分享 m技术分享 . (1≤n≤100000,1≤m≤100000)技术分享

The second line contains n技术分享 numbers, ranged from 0技术分享 to n−1技术分享 , the i技术分享 -th number of which represents a技术分享i−1技术分享技术分享 .

The third line contains m技术分享 numbers, ranged from 0技术分享 to m−1技术分享 , the i技术分享 -th number of which represents b技术分享i−1技术分享技术分享 .

It is guaranteed that ∑n≤10技术分享6技术分享,技术分享 ∑m≤10技术分享6技术分享技术分享 .
 

 

Output
For each test case, output "Case #x技术分享 : y技术分享 " in one line (without quotes), where x技术分享 indicates the case number starting from 1技术分享 and y技术分享 denotes the answer of corresponding case.
 

 

Sample Input
3 2 1 0 2 0 1 3 4 2 0 1 0 2 3 1
 

 

Sample Output
Case #1: 4 Case #2: 4

HDU 多校1.7

标签:mit   hdu   multiple   perm   time   ram   out   ssi   java   

原文地址:http://www.cnblogs.com/Roni-i/p/7233430.html

踩
(0)
赞
(0)
   
举报
评论 一句话评论(0)
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!