编程介的小学生 2017-01-01 09:39 采纳率: 20.5%
浏览 955
已采纳

Three Eggache God

问题描述 :

Alpheus has n monsters,their heights are A1,A2,A3….An. God Kufeng has n sons,their heights are 1,2,3….n.
One day, Our daredevil God Kufeng wants to challenge Alpheus. He sends his n sons to fight with Alpheus’s n monsters ,the i-th son fighting with the i-th monster. During one challenge,if the i-th son’s height is equal or greater than the i-th monster’s height,the i-th son will get one score for his father,else,he’ll get nothing.
Since Alpheus is strong enough to accept an infinity number of challenges,God Kufeng can challenge Alpheus again and again,but he has to change his son’s order after every challenge,and the same permutation can not appear more than once.(that is,God Kufeng has n! times to challenge Alpheus).
Now,God Wu–the god of universe,wants to make things difficult to Kufeng.He has n sons too,their heights are W1,W2,W3….Wn(it is a permutation of 1,2,3…..n),God Wu said to Kufeng: Only when the lexicographic order of your sons’ heights is bigger than my son’s,you can challenge my lovely Alpheus!
Question:What is the total score God Kufeng can get?Output the answer mod 1000000007.
Note:
Alpheus will never change his monster’s order,God Wu will never change his son’s order.
For two permutation A and B,if Ai=Bi for all i(1<=i<=n),we say A=B.else,we get the smallest i that Ai!=Bi,if Ai>Bi,we say A’s lexicographic order is bigger than B,otherwise,B is bigger than A.
输入:

First,there is an integer T(T<=20),the number of test cases.
For every case,there are three lines.
The first line is an integer n(1<=n<=2000),the number of sons of God Kufeng.
The second line has n integers,W1,W2,W3…..Wn,the heights of God Wu’s sons.(we guarantee that W1,W2,W3…..Wn is a permutation of 1,2,3….n).
The third line also has n integers, A1,A2,A3….An(1<=Ai<=n),the heights of Alpheus’s monsters.
输出:

First,there is an integer T(T<=20),the number of test cases.
For every case,there are three lines.
The first line is an integer n(1<=n<=2000),the number of sons of God Kufeng.
The second line has n integers,W1,W2,W3…..Wn,the heights of God Wu’s sons.(we guarantee that W1,W2,W3…..Wn is a permutation of 1,2,3….n).
The third line also has n integers, A1,A2,A3….An(1<=Ai<=n),the heights of Alpheus’s monsters.
样例输入:

2
3
3 1 2
1 2 3
3
3 2 1
1 1 1
样例输出:

Case #1: 2
Case #2: 0

  • 写回答

1条回答

  • threenewbee 2017-01-05 15:50
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值