LCM^k
Practice
3.7 (69 votes)
Basic math
Algorithms
Math
Problem
91% Success 29231 Attempts 30 Points 2s Time Limit 256MB Memory 1024 KB Max Code
Given three integers N,M,K and array of integers a1,a2,...,an.
Find the value of LCM(a1k,a2k,...,ank) mod M, where LCM means Least Common Multiple.
Input
The first line of the input contains a single integer T denoting the number of test cases(1 ≤ T ≤ 10).
The description of T test cases follows.
First line contains three positive integers N, M, K(1 ≤ N ≤ 3 * 105, 1 ≤ M, K ≤ 109).
The second line contains N space-separated integers a1,a2,...,an.(1 ≤ ai ≤ 106,1 ≤ i ≤ N).
Output
For each test case print the value of LCM(a1k,a2k,...,ank) mod M.
Submissions
Please login to view your submissions
Similar Problems
Points:30
8 votes
Tags:
Ad-HocMathematicsMediumOpenApprovedMathamatics
Points:30
1 votes
Tags:
MediumStringsSimple-math
Points:30
1 votes
Tags:
Medium
Editorial