hdu5399 Too Simple
来源:互联网 发布:网络硬盘录像机 编辑:程序博客网 时间:2024/06/10 11:59
Problem Description
Rhason Cheung had a simple problem, and asked Teacher Mai for help. But Teacher Mai thought this problem was too simple, sometimes naive. So she ask you for help.
Teacher Mai hasm functions f1,f2,⋯,fm:{1,2,⋯,n}→{1,2,⋯,n} (that means for all x∈{1,2,⋯,n},f(x)∈{1,2,⋯,n} ). But Rhason only knows some of these functions, and others are unknown.
She wants to know how many different function seriesf1,f2,⋯,fm there are that for every i(1≤i≤n) ,f1(f2(⋯fm(i)))=i . Two function series f1,f2,⋯,fm and g1,g2,⋯,gm are considered different if and only if there exist i(1≤i≤m),j(1≤j≤n) ,fi(j)≠gi(j) .
Teacher Mai has
She wants to know how many different function series
Input
For each test case, the first lines contains two numbersn,m(1≤n,m≤100) .
The following arem lines. In i -th line, there is one number −1 or n space-separated numbers.
If there is only one number−1 , the function fi is unknown. Otherwise the j -th number in the i -th line means fi(j) .
The following are
If there is only one number
Output
For each test case print the answer modulo 109+7 .
Sample Input
3 31 2 3-13 2 1
Sample Output
1HintThe order in the function series is determined. What she can do is to assign the values to the unknown functions.
解答:
这道题目比赛那会已经想出来规律,队友去敲的代码,只是注意几点小地方就行。判断有没有一行中有重复的数字。如果不存在-1,判断是不是符合那个条件。
0 0
- hdu5399 Too simple
- hdu5399 Too Simple
- hdu5399 Too Simple
- hdu5399(2015多校9)--Too Simple
- hdu5399 Too Simple(函数映射)
- hdu5399 Too Simple(推论,分类讨论)
- hdu5399
- hdu5399
- HDU5399
- too young too simple
- too young too simple
- too young too simple
- HDU 5399 Too Simple
- 【HDOJ 5399】Too Simple
- HDU 5399 Too Simple
- HDOJ 5399 Too Simple
- hdu 5399 Too Simple
- Keep it simple but not too simple
- JAVA读取外部资源的方法
- 怎样花两年时间去面试一个人
- HDOJ 1108 最小公倍数
- snprintf 在 linux 和 windows 平台上的差别
- 汇编中的寄存器
- hdu5399 Too Simple
- [LeedCode OJ]#204 Count Primes
- 关于show the Debug navigation不显示CPU Memory等信息
- 搭建zoneminder筆記
- vs2015 "行号显示"设置(vs简单使用)
- C++中指针使用小结
- 使用crontab命令定时执行脚本
- 软件公司主要防泄密点
- HDU 1115 Lifting the Stone(多边形重心)