
19

Why is map not working in this problem!
source link: http://codeforces.com/blog/entry/104260
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Why is map not working in this problem!
Problem : This is last round problem C.
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll mod = 1e9+7;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
ll t;
cin >> t;
while(t--){
ll n, m;
cin >> n >> m;
vector<ll>arr1(n);
for(ll i = 0;i<n;i++)cin >> arr1[i];
ll z;
cin >> z;
vector<ll>arr2(z);
for(ll i = 0;i<z;i++)cin >> arr2[i];
map<ll, ll>mp1, mp2;
for(ll i = 0;i<n;i++){
ll x = arr1[i];
ll cnt = 1;
while(x % m == 0){
x = x * 1ll / m * 1ll;
cnt = cnt * m * 1ll;
}
mp1[x] += cnt;
}
for(ll i = 0;i<z;i++){
ll x = arr2[i];
ll cnt = 1;
while(x % m == 0){
x = x * 1ll / m * 1ll;
cnt = cnt * m * 1ll;;
}
mp2[x] += cnt;
}
if(mp1 == mp2){
cout << "Yes" << endl;
}
else cout << "No" << endl;
}
}
</div
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK