543 - 競程 CPE 班 (2013/11/21) Scoreboard

Time

2013/11/21 19:05:00 2013/11/21 22:05:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
9046 Big Mod
9047 Determinant of A Matrix

9046 - Big Mod   

Description

Calculate R = (BP) mod M for large B, P, and M. Integer B and P are in the range 0 to 2147483647 (=231 – 1) inclusive. Integer M is in the range 1 to 46340 inclusive. Note you cannot calculate R directly because M is too large.

Input

There are multiple test cases. Each test case is given in three lines, containing B, P, and M in each line.

Output

For each test case, output the answer R in a single line.

Sample Input  Download

Sample Output  Download

Tags




Discuss




9047 - Determinant of A Matrix   

Description

Given an n×n matrix A,

                                                                                   ,

its determinant can be defined recursively as follows.

                                                                                   

where M­1,j is an (n–1)×(n–1) matrix, defined by removing the first row and the jth column of A,

                                                                                   

For example,

                                                                                  

                                                                                  
.

Input


The first line contains an integer t (1 <= t <= 20), which indicates the number of test cases in the input. Each case starts with an integer n (2 <= n <= 8), specifying the size of the square matrix A. Then following next n lines, each line containing n integers, define the entries of the matrix A. The range of values in the entries is from -5 to 5.

Output

For each case, output one line with the determinant of matrix A.

Sample Input  Download

Sample Output  Download

Tags




Discuss