300175: CF37D. Lesson Timetable

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Lesson Timetable

题意翻译

## 题目大意 P某人所在的大学有 $ m $ 间教室, $ n $ 个小组,对于第 $ i $ 间教室,初始时有 $ x_i $ 组在这个教室,且这个教室最多可以供 $ y_i $ 组同时上课。 每组学生第一次上课的教室的编号小于等于第二次上课的教室的编号。 P某人想为这些小组制定时间表,时间表有 $ 2n $ 个数,对于每个组,求第一节课和第二节课的教室标号。 你只需要求出共有多少种分组方法,不需求出具体方案。 由于答案可能很大,输出取模 $ 10^9+7 $ ## 输入格式 第一行包含一个整数 $ m $ ( $ 1 <= m <= 1001 $ )表示教室的数量。 第二行包含 $ m $ 个以空格分隔的整数 $ x_i $ ( $ 0 <= x_ i <= 100 $ )表示教室中的小组数量。 第三行包含 $ m $ 以空格分隔的整数 $ y_i $ ( $ 0 <= y_i <= 100 $ )表示教室中可同时容纳的最大人数。 保证所有 $ x_i <= y_i $ ,以及所有 $ x_i $ 为正且不超过 $ 1000 $ 。 ## 输出格式 在单行输出问题的答案 (计划表的数量取模 $ 10^9+7 $ ) ------------ Translation by MC小萌新.

题目描述

When Petya has free from computer games time, he attends university classes. Every day the lessons on Petya’s faculty consist of two double classes. The floor where the lessons take place is a long corridor with $ M $ classrooms numbered from $ 1 $ to $ M $ , situated along it. All the students of Petya’s year are divided into $ N $ groups. Petya has noticed recently that these groups’ timetable has the following peculiarity: the number of the classroom where the first lesson of a group takes place does not exceed the number of the classroom where the second lesson of this group takes place. Once Petya decided to count the number of ways in which one can make a lesson timetable for all these groups. The timetable is a set of $ 2N $ numbers: for each group the number of the rooms where the first and the second lessons take place. Unfortunately, he quickly lost the track of his calculations and decided to count only the timetables that satisfy the following conditions: 1\) On the first lesson in classroom $ i $ exactly $ X_{i} $ groups must be present. 2\) In classroom $ i $ no more than $ Y_{i} $ groups may be placed. Help Petya count the number of timetables satisfying all those conditionsю As there can be a lot of such timetables, output modulo $ 10^{9}+7 $ .

输入输出格式

输入格式


The first line contains one integer $ M $ ( $ 1<=M<=100 $ ) — the number of classrooms. The second line contains $ M $ space-separated integers — $ X_{i} $ ( $ 0<=X_{i}<=100 $ ) the amount of groups present in classroom $ i $ during the first lesson. The third line contains $ M $ space-separated integers — $ Y_{i} $ ( $ 0<=Y_{i}<=100 $ ) the maximal amount of groups that can be present in classroom $ i $ at the same time. It is guaranteed that all the $ X_{i}<=Y_{i} $ , and that the sum of all the $ X_{i} $ is positive and does not exceed $ 1000 $ .

输出格式


In the single line output the answer to the problem modulo $ 10^{9}+7 $ .

输入输出样例

输入样例 #1

3
1 1 1
1 2 3

输出样例 #1

36

输入样例 #2

3
1 1 1
1 1 1

输出样例 #2

6

说明

In the second sample test the first and the second lessons of each group must take place in the same classroom, that’s why the timetables will only be different in the rearrangement of the classrooms’ numbers for each group, e.g. $ 3!=6 $ .

Input

题意翻译

## 题目大意 P某人所在的大学有 $ m $ 间教室, $ n $ 个小组,对于第 $ i $ 间教室,初始时有 $ x_i $ 组在这个教室,且这个教室最多可以供 $ y_i $ 组同时上课。 每组学生第一次上课的教室的编号小于等于第二次上课的教室的编号。 P某人想为这些小组制定时间表,时间表有 $ 2n $ 个数,对于每个组,求第一节课和第二节课的教室标号。 你只需要求出共有多少种分组方法,不需求出具体方案。 由于答案可能很大,输出取模 $ 10^9+7 $ ## 输入格式 第一行包含一个整数 $ m $ ( $ 1 <= m <= 1001 $ )表示教室的数量。 第二行包含 $ m $ 个以空格分隔的整数 $ x_i $ ( $ 0 <= x_ i <= 100 $ )表示教室中的小组数量。 第三行包含 $ m $ 以空格分隔的整数 $ y_i $ ( $ 0 <= y_i <= 100 $ )表示教室中可同时容纳的最大人数。 保证所有 $ x_i <= y_i $ ,以及所有 $ x_i $ 为正且不超过 $ 1000 $ 。 ## 输出格式 在单行输出问题的答案 (计划表的数量取模 $ 10^9+7 $ ) ------------ Translation by MC小萌新.

加入题单

算法标签: