-
Notifications
You must be signed in to change notification settings - Fork 16
/
sumita and equal array
64 lines (57 loc) · 1.43 KB
/
sumita and equal array
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*
Sumita is playing with a Array A of size N. she wants to make all the values of A to be equal. she can multiply any value any number of times
by X, Y and Z. Your task is to tell her whether she can do it or not. Print "She can" if she can do it else print "She can't" without ""
Input :
First line of the input will contain T (No. of test cases).
For each test case, first line will contain four space separated integers denoting N, X, Y and Z.
Then next line will contain N space separated integers of A
Output :
For every test case, print the required answer in a new line.
Constraints :
1 ≤ T ≤ 5
2 ≤ N ≤ 10^5
X, Y, Z ∈ {2, 3, 5, 7}
1 ≤ Ai ≤ 10^9
SAMPLE INPUT
2
2 2 2 2
2 4
3 2 3 2
2 6 7
SAMPLE OUTPUT
She can
She can't
Explanation
Test case #1: Multiply first value by 2.
Test case #2: Not possible.
*/
#include <bits/stdc++.h>
using namespace std;
int main(){
int t; cin>>t; while(t--){
int n,x,y,z,t; cin>>n>>x>>y>>z;
int a[n],flag=0;
for(int i=0; i<n; i++){
cin>>t;
while(t%x == 0){
t/=x;
}
while(t%y == 0){
t/=y;
}
while(t%z == 0){
t/=z;
}
a[i]=t;
}
for(int i=1; i<n; i++){
if(a[0]!=a[i]){
flag=1;
break;
}
}
if(flag) cout<<"She can't\n";
else cout<<"She can\n";
}
return 0;
}