Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int main(){
- int n;
- cin >> n;
- for(int i=0;i<n;i++){
- int num;
- cin >> num;
- bool ok = false;
- for(int d = 1; d * d <= num; d++){
- if(num % d) continue;
- int a=d, b=num/d;
- multiset<int> l, r;
- int c = a;
- while(c){
- l.insert(c%10);
- c/=10;
- }
- c = b;
- while(c){
- r.insert(c%10);
- c/=10;
- }
- if(a%10 == 0 && b%10==0) continue;
- multiset<int> res;
- for(int aa: l) res.insert(aa);
- for(int bb: r) res.insert(bb);
- if(!(l.size() == res.size()/2 && r.size() == res.size()/2)){
- continue;
- }
- c = num;
- while(c){
- if(res.find(c%10) == res.end()){
- res.insert(-1);
- break;
- }
- res.erase(res.find(c%10));
- c/=10;
- }
- if(res.size() == 0){
- ok = true;
- break;
- }
- }
- if(ok){
- cout << "YES" << endl;
- }
- else{
- cout << "NO" << endl;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement