@@AppMaruf im not sure but ig c++20 comes up with some optimization in stl and better run time behaviour, so due to that the same solution got accepted which is giving tle in c++17
The algorithm for problem B is is giving wrong answer on 8 th test case in java: import java.util.*; public class State{ public static void main(String args[]) { Scanner scm=new Scanner(System.in); int t=scm.nextInt(); for(int a=1;a
I am a c++ user but from I guess I think your Math.sqrt() function takes double for input, but you need long double for input, so you should use binary search for taking out the sqrt or check out if there is a function in java that takes long double for input. Similar thing happened to me where my sqrt() function didn't worked, so I had to use sqrtl() which is new to me
Why we are still looking for mid in the else statement after setting answer equal to mid? In the else statement why we are still doing r=mid-1 after setting the answer equal to mid? In the problem B.
Because we have to minimize our n There can be multiple n for which exactly k bulbs will light up and we have to choose the minimum no of bulbs hence once we get an possible n we are storing it in answer and looking for smaller n to check wether can we achieve the desired state of exactly k bulbs that are on
we want to find the minimum answer, when our on > n that means we have a value which can be our answer but as we want the minimum value we will look on left side to find the least value
The first code is now giving tle on 5th test case UPDATE: Sorry guys I was submitting In c++ 17 which is getting tle whereas c++20 It is getting accepted no idea why
please help me same code in c++ why not run in java. import java.util.Scanner; public class problema { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while (t-- != 0) { long k = sc.nextLong(); long maxans = (4 * (long) Math.pow(10, 18)) ; long low = 1L; long high = maxans; long myans = 0L;
Please fill the feedback form for PCD: forms.gle/TamiaQyjCaXYobzP7
your explanations are crisp and to the point! Love it
Can u explain why we will use c++ 20? in A
Nice explanation sir, i have never solved problems on probability and modular inverse. Solution was a great help
Problem C - Is this a general way to solve such Bitwise equations ?
And can work in almost all such equations ?
Very great explanation
hey ,where to practice mathematical question like 1st or 2nd one.
past div 2 a,b questions
IQ + previous mathematics Olympiad exp
search project euler hackerRank
Atcoder beginner contests
Hey can you please add time stamps for A, B , C, D, E so that we navigate easily
use long long and submit in c++20 (if anyone getting tle)
Can u explain why we will use c++ 20?
@@AppMaruf im not sure but ig c++20 comes up with some optimization in stl and better run time behaviour, so due to that the same solution got accepted which is giving tle in c++17
E constraints were too tight. This complexity N*M is not expected for E.
Great explanation for B
Can u explain the time complexity of A?
Using dfs on graphs in D gives MLE on test case 7
You need to optimise adding edges. Like in my solution code, if you replace DSU.unionset by the push_back we do for graphs, it should work
The algorithm for problem B is is giving wrong answer on 8 th test case in java:
import java.util.*;
public class State{
public static void main(String args[])
{
Scanner scm=new Scanner(System.in);
int t=scm.nextInt();
for(int a=1;a
I am a c++ user but from I guess I think your Math.sqrt() function takes double for input, but you need long double for input, so you should use binary search for taking out the sqrt or check out if there is a function in java that takes long double for input. Similar thing happened to me where my sqrt() function didn't worked, so I had to use sqrtl() which is new to me
@@colgate1602 thanks buddy !!
I just copy and paste your code(problem A). But it's getting TLE in 5th test case ?
Yea, It's TLE, they are expecting O(n)
Try submitting in c++ 20 it will work
@@GopalYadav-re5rm Can u explain why we will use c++ 20?
Why we are still looking for mid in the else statement after setting answer equal to mid?
In the else statement why we are still doing r=mid-1 after setting the answer equal to mid?
In the problem B.
Because we have to minimize our n
There can be multiple n for which exactly k bulbs will light up and we have to choose the minimum no of bulbs
hence once we get an possible n we are storing it in answer and looking for smaller n to check wether can we achieve the desired state of exactly k bulbs that are on
we want to find the minimum answer, when our on > n that means we have a value which can be our answer but as we want the minimum value we will look on left side to find the least value
problem A is giving tle in test 3 in java
yes, check codeforces editorials they do upload the codes.
The first code is now giving tle on 5th test case
UPDATE: Sorry guys I was submitting In c++ 17 which is getting tle whereas c++20 It is getting accepted no idea why
i used similiar approach and got accepted , u might be be going wrong somewhere with the loop causing an infinite loop.
@@tervicke487 Can you share your code? I am getting TLE on 5th too.
Its probably because I have defined int as long long in my code and you haven’t causing an integer overflow
@@gaurishbaliga3723 It's Time Limit Exception, not any other kind of error.
@@mahadevpnair3196Do share your code, let me look into it
When Update problem F my bro, i really wanna solve that
Gaurish sir is lit🔥🔥
Rolfson Parkway
can u explain this in case of k = 10 ^ 18 its answer = 1000000001000000000 why not its 1000000000099999999??
use sqrtl instead of sqrt to compute square root
please help me same code in c++ why not run in java.
import java.util.Scanner;
public class problema {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while (t-- != 0) {
long k = sc.nextLong();
long maxans = (4 * (long) Math.pow(10, 18)) ;
long low = 1L;
long high = maxans;
long myans = 0L;
while (low
g
w