Help required MYSARA MARCH COOKOFF

Idk. You’re reallocating memory to num log n times, which drastically slows down your code. I don’t know how you would do it faster without inbuilt functions.

int solve(int n){
	ll res=1;
	for(int i=0;i<31;i++){
		ll ctr=0;
		for(int j=0;j<n;j++){
			int x = a[j] & (1 << i);
			if(x) ctr++;
			if(x==0 && ctr>0) return 0;
		}

		//cout << ctr << endl;
		if(ctr) res=(res*(ll)pow(2,ctr-1))%mod;
	}

	return (int)res;
}`

Please help. Is my logic correct? @everule1

Please format it using ``` above and below the code or link your submission.

Can you please check now.

pow(2,ctr-1) will most certainly overflow, and may also be inaccurate due to floating point values.

Is logic correct apart from that?

Help me find the mistake in my solution

https://www.codechef.com/viewsolution/30669799