@Karan Mashru #include class Solution { public: int find_gcd(int a , int b){ if(b == 0)return a ; else return find_gcd(b , a % b) ; } public: bool check(int divisor1 , int divisor2 , int uniqueCnt1 , int uniqueCnt2 , int mid , int lcm){
} public: int minimizeSet(int divisor1, int divisor2, int uniqueCnt1, int uniqueCnt2) { int lo = 1 , hi = INT_MAX , ans = 0 ; int lcm = ((long long)divisor1 * (long long)divisor2) / find_gcd(divisor1 , divisor2) ;
(Subscribe for more such videos)
Code :
class Solution {
public:
long gcd(long a, long b)
{
if((a%b)==0){
return b;
}else{
return gcd(b, a%b);
}
}
void bs(long l, long h, int divisor1, int divisor2, long lcm, long * ans, int c1, int c2){
if(l
WHat is the reason to choose 10^10 as the upper limit for the search space?
Very helpful video thank you so much!!!
Bhai atcoder ke solution bhi post kiya kro , kaafi helpful h tmhre video
app bahut accha padhate ho kash mai 3rd year m apka channel dekha hota
Thanks for that explanation...❤
oh..bhai...mza agya....I like the explanation which is beginner friendly. Thanks
Very nice explanation ...#concept clearr👍👍
Are you doing #6comp30days challenge by arsh goyal??
bhaii sab kya question tha and kya explaination hai
Good job
very good explanation
Very well explained.. thanku sir
Are you doing 6comp30day challenge by arsh goyal??
@@ManishkumarRajakCS-- yes
@Karan Mashru
#include
class Solution {
public:
int find_gcd(int a , int b){
if(b == 0)return a ;
else return find_gcd(b , a % b) ;
}
public:
bool check(int divisor1 , int divisor2 , int uniqueCnt1 , int uniqueCnt2 , int mid , int lcm){
int temp1 = mid - mid/divisor1 , temp2 = mid - mid/divisor2 ;
int temp3 = mid - (mid/divisor1 + mid/divisor2 - (mid / lcm)) ;
int temp4 = mid - (mid / lcm) ;
if((temp1 >= uniqueCnt1) && (temp2 >= uniqueCnt2) && ((temp1 + temp2 - temp3) >= (uniqueCnt1 + uniqueCnt2)))return true ;
else return false ;
}
public:
int minimizeSet(int divisor1, int divisor2, int uniqueCnt1, int uniqueCnt2) {
int lo = 1 , hi = INT_MAX , ans = 0 ;
int lcm = ((long long)divisor1 * (long long)divisor2) / find_gcd(divisor1 , divisor2) ;
while(lo
just use long it will give you correct answer