 What's up guys, my name is Michael and welcome to my YouTube channel. Today we're going to go over codeforces global round eight a plus a c plus equal to a c plus equal. Yeah, that's that's basically what this problem is. So Leo has developed a new programming language c plus equal. It just adds a value to the left to the right. So now you could basically in a prototype program Leo wants has a two integer variables a and b and he can perform any number of operations where you could a plus equal to b or b plus equal to a and he wants to test the handle of large integers. He wants to make sure the value of either a or b strictly greater than n. So what is the minimum number of operations he has to perform? So a plus equal to b basically just does is that it adds a and b and it sets a equal to the new value. So if a is two and b is three, a plus equal to b would be two plus three is going to equal to five. And now the new value of a is going to equal to five. So that's what a plus equal to b is. If it's b plus equal to a would add a and b and then the new value becomes b. So now our job is that we could perform any number of operations where you do a plus equal to b or b plus equal to a but you want to make sure the value of it you could do any number of these operations. You have to make sure the value is strictly larger than n. So now our job is a question is is that what is the smallest number of operations you have to perform with either a plus equal to b or b plus equal to a so to make a or b strictly larger than n. And then the test case is that you have the first number of test cases and then you have a b and n. Okay, so what exactly this is actually not a hard problem and I actually solved this in one go. So you basically just recode exactly what this these lines are. So I'm going to explain the solution with you guys. Uh, what I did there's like there's like a better way to do it but is how I did it. Okay, so we have to read a number of test cases and then we have to read in a b and n. Okay, so what do I do first? Um, I did I have first if I checked whichever is the larger value and I swapped it. This basically just lets me put the larger value in the first first location. Right, so if I had like a larger value a is greater than b or a is less than b, right? This would allow me to this this statement if a is less than b, then swap a b. This basically always puts the larger value of a and b into a. Right, so a is going to always have a larger value. I did this because I just wanted to make sure that my a is the larger value. Okay, because the reason why I'm able to do this is because it really doesn't matter. If you think about it, if I do a plus equal to b or b plus equal to a, it really doesn't really matter which one has a larger value. Right, the number of operations that really doesn't matter because as long as the first value has a larger, larger, larger value. Um, second one doesn't really matter. Right, like I don't really care about the smaller one or larger, but I'll go, I'll get back to this later. So what do I do? I had a counter for the number of operations I want to have, right? Because I'm counting the number of operations I want to do. So basically remember the question is, is that I'm going to add a plus equal to b. I could either add a plus equal to b or I could add b plus equal to a. Right, that's the two operations I could possibly do. Right, and I want to make these value two values strictly larger than n. Right, either of these two values strictly larger than n. So I need a variable to count the number of operations I'm doing. Right, because they're asking, what is the smallest number of operations needed to make these two, uh, needs to make either one of these strictly larger than n. So that's why I had number of operations, a variable to keep track of the number of operations. So I didn't int op equals zero. All right. So then what I do, I had a while, infinite while loop, and ideally you're not supposed to do this, but I was running out of time. Right. I actually, when I did this contest, I actually did C first and I couldn't actually figure that out. So I went to B, then I got errors on B. So I was like, okay, you know what, I have to do a to get some points. So that I did a in like 30 minutes left or something. But yeah, I should have done a first action now thing about it. But yeah, yeah, I didn't have that much time. So that's why I did a while true. But basically what I did was I have an infinite loop all right. And this while loop is just going to keep running this while it was just going to keep running. So what do I do? So first, because I always put the smaller value, the not not smaller, the larger value, I always put the larger value as a so a is always going to have the larger value right after this if statement because I swapped a to be a and b I swapped them if a is less than b. So that means a always has a larger value. So that's why I had this if statement right and reason why I kept the first part to have the larger value is because for B, I'm going to add equal to a right. So that's one operation. I'm going to add B plus equal to a right. So that will force my B to have the larger value now. Right. So a originally had a large value like the larger values like let's say, let's say a was one, one and then B was two. Right. So now at this condition if a is less than b, I'm going to swap it. So now a is equal to two and B is equal to one. Right. So then during this while loop, I'm going to do B plus equal to a. So what does that do that adds B to a. So then one plus two would now becomes three. So now B is equal to three. So they basically, this is taking the smaller value and I'm adding the larger value to the smaller value. Okay, that's what I'm doing on B plus equal to a. This is like one of the type of operations we could do. Remember, guys, there was two types of operations we could do a plus equal to B, or we could do B plus equal to a. So because I swapped the first value to have the smaller value, I made the second because I made the first value, the larger value, right? In this case, because of the if a is less than B. So the first value always has a larger value, right? Between these two numbers a and B, a has a larger value, right? Because I swapped them if a is less than so a is going to be larger than B. So because of this, I made sure to add B first, right? Because now B is going to have if I do B plus equal to a, B now has a larger value, right? So after I add B's value with A's value, and I set that new value of B to be B plus equal to a, now B is going to be larger than a, right? That's why I did this. Okay, so I did B plus equal to a first. This is just because of that. Then I did operation plus plus. Okay, the reason why I did this is because you had to add one for an operation. So remember, back into the question, you could either add one, you could either do a plus equal to B, or you could do B plus equal to a, and you want the minimum number of operations it takes to either of one of these to get one of them to be greater than n, right? The value n. So that's why you have to add one. I did operations for my number of operations. I had to add one, okay? Because that's one operation. B plus equal to a is one operation. It's like another operation I'm adding. So I did operation plus plus. Okay, so now this is why I did. If B is greater than n, I break. Why did I do this? Because after this loop, remember, we want one of the values of a or B to be strictly larger than n. So because of that, we want, if one of them, if B is greater than n, I have to break out of the loop, right? Because otherwise I'm just going to keep adding operations over and over again. I'm going to keep doing B plus equal to a plus equal to B, stuff like that, yada, yada, yada. That's not good, right? That's why I break out a loop if that occurs. So if I do break out a loop, let's say B is greater than n, I break out a loop, then I just print out the number of operations, right? Because that would be the minimum number of operations that is needed, right? If I break out a loop, that means B is greater than n, my number of operations, I'm done. So I just print out operations. All right, otherwise, I have, if that's still not the case, now I do the other operation, right? So remember we had, we could do B plus equal to a, or we could do a plus equal to b. So because of that, now I'm going to do the other operation, which is a plus equal to b, right? A plus equal to b now adds B's value to a, and a's value now increases. So now a is the greater value now, right? Now I'm going to do operation plus plus, and this is counting another operation that I just did. So a plus equal to b now, operation plus plus. Now, if a is greater than n, I break. The reason why I have to do this is because remember, if either a is greater than n or b is greater than n, you're done, right? We're done. We want the minimum number of operations, either a or b is greater than n. So if either one of these occurs, then we break out of our loop and then just print out the operation. Otherwise, it's just going to continue in this while true loop, and then it'll finish sooner on. So yeah, that's basically how you do it, pretty much. You add, you do b plus equal to a, you add, you do one operation, and then you check if it's greater than it, if it's greater than n, but as you break, otherwise you do another, the other operation, which is a plus equal to b, and you add it, add one, and then you check if it's greater. If it is, if it's not, if it is, we break. And then, yeah, if it breaks, when we just print out the number of operations, and then we're done. That's pretty much it. So if I go back to the code, that's, yeah, that's basically how you do this problem. Remember, we only want the minimum number of operations to have the value strictly greater than n. And that's what the point of it is. That's the point of this code. That's what it does. I got a seed, rate, comp, subscribe. That's basically how you do this problem. Remember, we just want, we could perform any operations a plus equal to b or b plus equal to a, and we just want either one of these a or b to be strictly larger than n. So that's what you do. All right. I hope you guys enjoyed this video. That was basically me explaining my, my solution of this code. Rate, comp, subscribe. I'll check you guys later. Peace.