#P7634. [COCI 2010/2011 #5] HONI
[COCI 2010/2011 #5] HONI
Description
The COCI problem setters must choose the tasks that will appear in the next round from a pool of tasks.
The difficulty of a task is described by an integer from to , but for some tasks it is not easy to determine their difficulty accurately. The COCI problem setters believe that such tasks can be treated as having one of two consecutive difficulties. For example, some tasks can be treated as having difficulty or .
The next COCI round will contain tasks. For each difficulty, there will be exactly one task. Of course, no task will appear twice.
Find the number of different ways the setters can choose the tasks for the next round. We consider two ways different only if the same task is assigned to different difficulties.
Since the expected result can be very large, output the number of ways .
Input Format
The first line contains an integer .
The second line contains integers , where the -th number represents the number of tasks whose difficulty is exactly .
The third line contains integers , where the -th number represents the number of tasks whose difficulty is or .
Output Format
Output one line with an integer, representing the number of ways .
3
3 0 1
0 1
3
4
1 5 3 0
0 2 1
33
Hint
[Sample Explanation #1]
There are ways in total: treat the tasks with difficulty or as difficulty . Since there are tasks with difficulty , there are ways in total.
[Constraints]
For of the testdata, , .
[Notes]
The score of this problem follows the original COCI setting, with a full score of .
This problem is translated from COCI2010-2011 CONTEST #5 T4 HONI.
Translated by ChatGPT 5
京公网安备 11011102002149号