Cake Walk
Practice
0 (0 votes)
Problem
69% Success 91 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code
Alice goes for a walk and notices \(N\) cakes where the \(i^{th}\) cake has value \(v_{i}\). Alice's initial \(happiness = 1\). Eating a cake of value \(X\) multiplies her \(happiness\) by a factor of \(X\). However, she finds two prime numbers peculiar \(A, B\). She will be very sad if her \(happiness\) is a multiple of both \(A\) and \(B\). What is the maximum number of cakes which she can eat?
Input Format
First-line has \(T\) indicating number of test cases.
Each test case is printed on a new line:
\(NABv_{1}..v_{N}\)
Output Format
Print answer for each test case on a new line.
Constraints
\(1 \leq T \leq 10 \\ 1 \leq N,A,B,v_{i} \leq 10^{5}\)
Submissions
Please login to view your submissions
Similar Problems
Points:20
Tags:
Easy
Points:20
42 votes
Tags:
ReadyBasic ProgrammingOpenEasyMathamatics
Points:20
3 votes
Tags:
Basic MathNumber theoryAlgorithmsMath
Editorial