Bhaiya, I want to ask How will we get intuition behind finding whole array LCM and then finding all divisors of that and all those divisors which are not present in the array finding their LCM and and then checking again whether that LCM is present in array or not and if not taking maxLength as answer.
non-present divisors is the candidate which can generate a number of his multiple not in the array, because main goal is the lcm of selected text must not present, and that number can generate as its not there in array at the first place
here is my code int n; cin>>n; vectora(n); sets; ll lcm=1; mapm; for (int i = 0; i < n; i++) { cin>>a[i]; s.insert(a[i]); lcm=(lcm*a[i])/__gcd(lcm,a[i]); m[a[i]]++; } if(s.find(lcm)==s.end()){ cout
Thank you so much Nicspyy for posting these helpful explanations ❤️
It's my pleasure
In C, why the answer for explained testcase is not 5 for the subsequence -> 3 2 10 20 1
LCM is 60, which is not present.
60 is there
It would be better if the volume was a bit higher.
will try to speak much louder from next time 😉
I would be lost if I didn’t have your help 🙇♂️
thank you for the compliment 😊
Bhaiya, I want to ask How will we get intuition behind finding whole array LCM and then finding all divisors of that and all those divisors which are not present in the array finding their LCM and and then checking again whether that LCM is present in array or not and if not taking maxLength as answer.
non-present divisors is the candidate which can generate a number of his multiple not in the array, because main goal is the lcm of selected text must not present, and that number can generate as its not there in array at the first place
Your chrome theme name pls ?
you can try searching "colors" on the web themes
B solution:
void solve(){
int n;
cin>>n;
int m = n;
vi a(32, 0);
forn(i,0,32){
a[i] = m%2;
m /= 2;
}
forn(i,0,32){
if(a[i] == 1 and a[i+1] == 1){
a[i] = -1;
i++;
while(a[i] == 1) a[i++] = 0;
a[i] = 1;
i--;
}
}
int ind = 31;
while(a[ind] == 0) ind--;
cout
I managed to scrape a 1984 MS solution for C -> 15 MS away from TLE LOL
great 👍❤
what is ur rating?
Less than an expert, 😊
@@nicspyywhy don't give u codeforces I'd....so that it can help us
@@manishkumar-uw5mw +1
@@manishkumar-uw5mw help in what manner 🙃🤔
@@nicspyy like looking soln help to understand thinking approach
1 4
3 8889 14815 44445 getting error on this test case i had implemented your logic
here is my code int n;
cin>>n;
vectora(n);
sets;
ll lcm=1;
mapm;
for (int i = 0; i < n; i++)
{
cin>>a[i];
s.insert(a[i]);
lcm=(lcm*a[i])/__gcd(lcm,a[i]);
m[a[i]]++;
}
if(s.find(lcm)==s.end()){
cout
bro taking reference from the code
same bro according to his logic this test case fails
@@BombSquadHindiTipsTricks send submission link