As to a permutation
Given the positive integers
The answer may be very large, so you only need to give the value of answer modulo
The input contains multiple test cases.
For each test case:
The first line contains one positive integer
The second line contains
The third line contains
It's guaranteed that the sum of
Warm Tips for C/C++: input data is so large (about 38 MiB) that we recommend to use fread() for buffering friendly.
size_t fread(void *buffer, size_t size, size_t count, FILE *stream); // reads an array of count elements, each one with a size of size bytes, from the stream and stores them in the block of memory specified by buffer; the total number of elements successfully read is returned.
For each test case, output "Case #
3 1 1 3 1 3 3 5 1 2 2 4 5 5 2 5 5 5
Case #1: 2 Case #2: 3