Computer Programming Monsoon 2012, Mid Semester II Lab Exam SetC
Computer Programming Monsoon 2012, Mid Semester II Lab Exam SetC
Computer Programming
Monsoon 2012, Mid Semester II Lab Exam
SetC: T5 & T6: 2 November 2012
Total Time: 2 Hrs
Problem1: LCM
Total Marks: 10
[1.5 (TestCase1) + 2.5 (TestCase2) = 4 Marks]
Given N numbers, find their LCM.
Input Format:
First line contains number of test cases.
Second line contains N â number of numbers
The next line contains N space separated integers whose LCM is to be found.
Output Format:
Print one line per test case containing the LCM of the N numbers
Sample Input :
3
3
123
2
12
5
15721
Sample Output:
6
2
70
Constraints:
1
1
1
Problem2: Matrix exponentiation
[2 (TestCase1) + 4 (TestCase2)= 6 Marks]
Given a matrix M, raise it to the power P.
NOTE: As the elements in the resultant matrix can be very large, print the elements modulo
1000000007
Input Format:
First line contains an integer T number of test cases. Then T test cases follow.
Each test case will contain two integers N and P in one line seperated by spaces. Then N lines
follow. In each line, there will be N integers seperated by spaces.
Output Format:
For each test case print N lines. In each line there should be N integers seperated by spaces.
Sample Input:
2
42
6319
5478
2913
1838
34
123
123
123
Sample Output:
62 111 55 153
72 158 64 162
62 75 75 117
60 126 84 146
216 432 648
216 432 648
216 432 648
Constraints:
1
1
0
Is this the question you were looking for? If so, place your order here to get started!