justforasking's blog

By justforasking, history, 3 months ago, In English

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;
  
 }
}

Read more »

 
 
 
 
  • Vote: I like it
  • +3
  • Vote: I do not like it

By justforasking, history, 3 months ago, In English

What will be your advice to newbie's and pupil's to do better at competitive coding which helped you a lot at that stage.

Read more »

 
 
 
 
  • Vote: I like it
  • -16
  • Vote: I do not like it

By justforasking, history, 3 months ago, In English

Can anyone tell me how to include this micro #define int long long int, this is giving error because its also converting int main to long long int main

Read more »

 
 
 
 
  • Vote: I like it
  • +6
  • Vote: I do not like it

By justforasking, history, 3 months ago, In English

Which type of problems to practice to able to solve this type of problems, got stuck in this problem.

Read more »

 
 
 
 
  • Vote: I like it
  • 0
  • Vote: I do not like it