# IPLPAWRI-Editorial

PRACTICE
Editorialist: Tirthankar Nath

Cakewalk

Number Theory

# PROBLEM:

DK after winning the first match in this season having a pawri tonight. In the pawri he is calculating the next match’s predictive score and outcome to strategise very strongly for the next matches. Now he writes down each team’s next match’s unique score on the sheets along with his team score. Suddenly all the sheets fly away on the ground and get mixed with others’ similar sheets and so each team’s unique scores are now Penta-times written. But fortunately DK’s team’s next match’s unique score only written thrice . Now find out the total sum of those three scores then only Pawri will begin.

# EXPLANATION:

The funda is as each unique value repeated 5 times so their set bits(non-set bits as well) repeated 5 times except DK’s unique value repeated three times . So that value’s set bits repeated three times . So here we check at every position of bits from 0 to 63 where Total Number of Set bits at j-th position%5==3 , as except those positions at all other positions Total Number of Set bits at j-th position%5=0 . Now find that unique value by binary to decimal conversion then multiply that by 3 to get the ans.

# SOLUTION:

``````#include <bits/stdc++.h>
using namespace std;
#define ll long long

int main()
{
ios::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);

int t;cin>>t;while(t--)
{
int n;cin>>n;vector<int> v(64,0);

ll a,number=0;

for(int i=0;i<n;i++){
cin>>a;
for(ll j=0;j<64;j++){if((1LL<<j)&a)v[j]++;}
}

for(int j=0;j<64;j++)
{
if(v[j]%5!=0)number+=(1LL<<j);
}

cout<<number*3<<endl;
}

return 0;
}
``````
1 Like