Can anyone tell me where i am wrong
#include<bits/stdc++.h>
using namespace std; #define ff first #define ss second #define int long long #define pb push_back #define mp make_pair #define pii pair<int,int> #define vi vector #define mii map<int,int> #define pqb priority_queue #define pqs priority_queue<int,vi,greater > #define setbits(x) __builtin_popcountll(x) #define zrobits(x) __builtin_ctzll(x) #define mod 1000000007 #define inf 1e18 #define ps(x,y) fixed<<setprecision(y)<<x #define mk(arr,n,type) type arr=new type[n]; #define w(x) int x; cin>>x; while(x–)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int M = 3e5+ 7, N = 500;
int fact[1001];
int power(int x, int y){
int res = 1;
x = x % mod;
if (x == 0) return 0;
while (y > 0){
if (y & 1)
res = (resx) % mod;
y = y>>1;
x = (x*x) % mod;
}
return res;
}
int ad(int a, int b){
return((a % mod + b % mod) % mod);
}
int sub(int a, int b){
return((a % mod - b % mod + mod) % mod);
}
int mul(int a, int b){
return(((a % mod) * (b % mod)) % mod);
}
int divi(int a, int b){
return(mul(a, power(b, mod - 2)) % mod);
}
I believe people don’t want a conversational editorial(though i understand you wanting to help).
We come across editorials only when you know we are fed up or we want a direction. So if you can change your structure of editorial like giving Hints initially, someone like me would prefer hints first over reading all this in one go.
Though I gave a 4 I mean it wasn’t bad it was a decent editorial.
Hi,
I am getting answer as
1073741823 0
1073741823 0
1073741823 0
even with the additional condition you suggested.
I think there is some error in the bits while calculating && or so, but am not able to figure out,
Hi,
This could be written as (2^30) - 1
<< is a left shift operator used for shifting the bits by one in each iteration where
1 << no_of_iterations ===> so 30 is no of iterations here.
You could read more about left shift operators
I have spent so much time building this solution , and i dont know what is wrong with my approach.
please do look at my solution and help me .
thanks in advance.
link :- sol
Can some one please explain the logic used for the loop for the solution linked to the editorial.
Why is it for(int msb = (1<<29); msb > 0; msb /= 2) Can we use msb - - ?
Why are we dividing it by 2 every time?
Thanks
msb refers to the most significant bit (which starts with 1<<29 and ends with 1<<0). The reasoning for this, and not iterating from 29 to 0 (as the editorial states) is ease of implementation, as I don’t have to bit shift every time I want to do an AND operation (lines 34,35,36,43,44 would have ...&msb replacd with ...&(1<<i) which is redundant)
Please help !
Why am I getting WA for Subtask 3.
Have used diff logic.
First checking what can be max allowed by all nums, then checking individually if the max is possible and updating val and count accordingly.