-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdivisibleandEqualize.cpp
More file actions
48 lines (45 loc) · 896 Bytes
/
divisibleandEqualize.cpp
File metadata and controls
48 lines (45 loc) · 896 Bytes
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
#include<bits/stdc++.h>
using namespace std;
void primeFactors(unordered_map<int, int> &mp)
{
// Print the number of 2s that divide n
int n;
cin>>n;
while (n % 2 == 0)
{
mp[2]++;
n = n/2;
}
for (int i = 3; i <= sqrt(n); i = i + 2)
{
while (n % i == 0)
{
mp[i]++;
n = n/i;
}
}
if (n > 2)
mp[n]++;
}
int main() {
int t;cin>>t;
while(t--) {
int n ;
cin>>n;
int a[n];
unordered_map<int, int> mp;
for (int i = 0 ; i < n ; ++i) {
primeFactors(mp);
}
bool ans = true;
for (auto it : mp) {
if (it.second %n != 0) {
cout<<"NO";
ans = false;
break;
}
}
if (ans) cout<<"YES";
cout<<endl;
}
}