Anshul
Ok ok
Anshul
Can you please tell me why this UB is occuring
Vlad
It just runs too many iterations
Vlad
So it still calculates it
Anshul
On your system it produced output?
Vlad
And you've got a double for loop
Vlad
So its (r - l) ^ 2 operations
Anshul
Yea
Anshul
Can you please tell me how to optimise it,
Anshul
The solution to this isn't provided and I have thought about it alot but can't think of anything
Vlad
Just clamp your inputs
Vlad
So they aren't as huge
Anshul
It's on some online judge, I can't make the input smaller
Vlad
What's your time limit?
Vlad
Does it exceed that?
Anshul
Yes it exceeds time limit
Vlad
Then you'd have to be more clever on how you do it
Anonymous
I wrote a code for a problem. For smaller values it runs perfectly. But for larger values it just don't print anything even after taking so much time
In your code, the statement in the inner loop executes close to 25 × 10^34 times. Assuming you execute it on the fastest supercomputer (not quantum computers) in existence today, it would take close to 10^16 years to finish running.
Anshul
*(r-i) iterations
Hirrolot
https://github.com/notfoundry/ppstep
Anonymous
It runs only (r-i ) loops
r-i in your case is 5 × 10^17. Check it out.
Anshul
So how should I tackle this problem?
Anonymous
hi i new in programming
𝗕𝗔𝗛𝗔𝗥‌
plesss who stdy informationn technology ? there say me 🥺
Anonymous
So how should I tackle this problem?
I dont know what the question is but usually in algorithmic contests, you cant use simple solutions. You will have to use a clever algorithm.
𝗕𝗔𝗛𝗔𝗥‌
𝗕𝗔𝗛𝗔𝗥‌
What do you want to learn brother
you stdy information technology
Anshul
you stdy information technology
I study computer science and electrical engineering
Anshul
no brother😂
Okk, you're a girl?
𝗕𝗔𝗛𝗔𝗥‌
Anshul
1st or 2st?
Both😅
𝗕𝗔𝗛𝗔𝗥‌
Anonymous
what's the error you get ?
artemetra 🇺🇦
i'm planning to read the "Accelerated C++" book, but i saw that it covers C++98. is it really outdated? if so, is there a similar "starting out in C++ with previous programming experience" book can you recommend?
Anonymous
I study computer science and electrical engineering
I also study computer and electrical eng.
𝗕𝗔𝗛𝗔𝗥‌
now no have nothing in there student IT ?😔🥺
Anshul
What's the error
Anshul
Put it after cout
Ayush Kumar
cout << "number 1 divide by number 2 = "; ("n1/n2"); This line is wrong, see what you have done at the end.
Anonymous
... this
int biggestXOR(long long l, long long r) { long long x = l^r; int pos = 0;     while (x)     {         pos++;         x >>= 1;     }     int result = 0;     int y = 1;     while (pos--)     {         result += y;         y <<= 1;     }     return result; }
Anonymous
sorry
Hanz
This is an interesting discussion, im listening...
Anonymous
I cant understand the logic, please explain
The logic is simple. We have to first determine the number of bits in the maximum xor value. The first while loop does that. The second loop just uses the bit size determined in the first loop and sets all bits to 1 and determines the number. The reason why the first loop gives the size of maximum xor value can be explained by an example. For ex if you take l = 3 (011) and r = 15 (1111) x will be 1100. Then pos will be 4 which is the maximum number of bits in the xor value. So the second loop returns 1111. Once the bit size is determined it is easy to see that it is a simple step to choose some values in the range which will return 1 for all bit positions lesser than the most significant bit which is pos. If l is 3 and r is 6 (110), then x is 101 and pos will be 3 bits. The value returned is 111.
Anshul
Second loop can be replaced by (1<<pos)-1
Anshul
How it is sure that the maximum xor will have only pos number of bits
Anonymous
How it is sure that the maximum xor will have only pos number of bits
Check the first bit of values from l to r. It either changes from 0 to 1 or stays 1 if it stays 1 we then consider the next bit and so on. If we take the maximum xor for 2 numbers in this range, this would be the leftmost 1 in the xor of l and r.
Anshul
Thanks 👍
Anonymous
final hihihihi
Anonymous
ok bye give me support
Anonymous
👋
Pradevel (Pratyush)
/get ide
GHAMDAN_NSHWAN
Anonymous
temp->h[ch]=child; What does this line actually mean? What's happening with temp? h is a hashmap and child is a new node created
Vlad
temp->h[ch]=child; What does this line actually mean? What's happening with temp? h is a hashmap and child is a new node created
You derefence temp, get it's member h, then take `ch`th element of an array h and assign child to that
Vlad
Consider revising your naming lol
Anonymous
You derefence temp, get it's member h, then take `ch`th element of an array h and assign child to that
I'm really having problem in understanding the code for Dictionary/ Auto Suggestion using Trie Can you help me understand it?
Anonymous
Consider revising your naming lol
maybe later, i'm the kek-est lol
Vlad
Pointers structure members and what not
Anonymous
yeah yeah i understand those well now but was having problem in this
Anonymous
Link (?)
https://pastebin.com/xDdfzbvC
V
https://pastebin.com/xDdfzbvC
The code looks like basic syntax, what exactly are you missing? Understanding algorithms through "readable syntax" is the next step in "understanding the language"
Sachin
int binarySearch(int arr[], int l, int r, int x) { while (l <= r) { int m = l + (r - l) / 2; if (arr[m] == x) return m; if (arr[m] < x) l = m + 1; else r = m - 1; } return -1; }
Sachin
can someone explain the time complexity of this
Sachin
Yes