首页 > 其他 > 详细

HDU 多校1.7

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

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 n1技术分享 and a permutation b技术分享 from 0技术分享 to m1技术分享 .

Define that the domain of function f技术分享 is the set of integers from 0技术分享 to n1技术分享 , and the range of it is the set of integers from 0技术分享 to m1技术分享 .

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

Two functions are different if and only if there exists at least one integer from 0技术分享 to n1技术分享 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技术分享 . (1n100000,1m100000)技术分享

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

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

It is guaranteed that n10技术分享6技术分享,技术分享 m10技术分享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

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!