My issue
plz resolve my doubts
in this que sum of the element of subsquence is divisible by m for good sequence.
but in ex.1–> subsequence is (1,2)–>(1+2)%3==0 then why not consider this pair.
My code
#include <bits/stdc++.h>
using namespace std;
int main() {
// your code goes here
int t,n,m,count;
cin>>t;
while(t--){
count=0;
cin>>n>>m;
int arr[n];
for(int i=0;i<n;i++){
cin>>arr[i];
}
unordered_map<int,int>mp;
for(int i=0;i<(1<<n);i++){
int sum=0;
for(int j=0;j<n;j++){
if(i & (1<<j)){
sum+=arr[j];
}
}
mp[sum]++;
}
for(auto pair:mp){
if(pair.first%m==0){
count+=pair.second;
}
}
cout<<count<<endl;
}
return 0;
}
Problem Link: MGCSET Problem - CodeChef