 What's it got today? We're going to go over the problem of building a fence. So Basically, you have a backyard and you you want to see the endpoints and then you want to build a fence the length l Switch at the area and close between the wall and the fence is maximized Okay, the fence could be any arbitrary shape, but it's two endpoints have to touch the wall so Yeah, so now what you had you're given is the length of the fence and then basically you want the largest area All right, so this problem is pretty stupid Basically, if you imagine like a backyard like this Right, this is like your backyard and you want to build a fence Imagine if you're this is one of your endpoints because the both of the endpoints have to stay on the same wall The only way you could do this is if you have like a giant semi circle like this Right because both of these endpoints have to stay on the same wall. That was from this to the problem statement So basically if we got both the endpoints have to stay on this this wall. So this is your wall Right, and then you're given the length of the arc. I think I think that's what you're given. Yeah Yeah, the length of the fence. So that's that's the arc length. That's this arc length So in order to solve this problem, you have to do This is what we got to do. So remember the area of a The circumference of a circle Right is a diameter times pi. So it's 2 pi r right where 2 r is the diameter and basically you have the What we're going to do is we're going to take the circumference of this circle and we're going to divide it by 2 Right and the reason why is because this area is actually a semi circle Right this this circumference this arc length is actually just a half of a semi circle so if you're given like Remember this this is this is the circumference of 2 pi r is the circumference of the total circle, right? And now we're only just want this part This part this arc Right ignore the the dot ignore this Right, we just want the half of the circle. So we're going to do is we're going to take the 2 pi r Which is the diameter or the circumference of the whole Not diamond. This is 2 pi r is going to be the whole circle, right? And we're going to divide it by 2 And this is going to equal to L Because that's of what we're given right so now we're going to cross out the 2 so now we're going to have pi r is equal to L Pi r is going to equal to L so now if you divide by Pi on both sides you get r is going to equal to L divided by pi so r is going to equal to L divided by pi Okay, so now you have L divided by pi and that's your r. Okay, so now what we want is we want to maximize the area So area is just the area of the whole Large area is just going to be like the pi r square. So now we have this we're going to do pi r square now. So we're going to do Yeah, we're going to do so so now we have the r radius of r. So now we're going to do pi Radius squared Pi radius squared, which is going to be It's going to be L over pi so Pi r squared right where ours are radius and our radius is L over pi. So we're going to do pi times L over pi squared and That's going to equal to pi L squared over Pi squared. So if you divide by pies on both sides, you get L squared over pi. So I think that's the answer. I believe that's the answer unless you have to divide by two again but I'm going to show you my code now so I'm going to go Show you guys a code now All right, so this is the code. Oh, yeah. Oh, yeah, you have to divide by two also my bad because You have to buy the two because it's a half the area half of the area, right? So we have to do L squared So we have to do L squared over pi and then divide by this by one half to also Go by two again My bad guys. I forgot so So our answer will be L squared divided by two pi So that's basically our answer So our answer is L squared. This is L squared divided by two pi Okay, so that's our answer. So, yeah Our tricky part of this part is that uh, you get some weird You keep getting the answer wrong if you if you round off around it incorrectly. So, yeah Here's a code. I do a do while because they want to end the they want to end the Input statement if you have if you input a zero so you have to end it So that's why I do so you so I had to do while t is not equal zero I read in t And then I just check if t is equal to zero then I break Otherwise I create this variable called x because uh, yeah And what I do is I take one divided by 2.0 and this makes it a float and multiply by t times t That's basically t square and then I multiply by one over pi, which is 3.141596 So that's basically just a bit The the only tricky part about this is that you could get like overflow air or something like that or your precision precision error Not overflow precision error. So that's why I haven't made sure my pi goes up to like six decimals more than six And I see out and make sure the precision is to two So that that's only two decimal places make sure it's fixed. So it actually rounds up by two decimal places Yeah, and I just print out X. So that's basically just the code That's basically how you do this problem Yeah, I hope you guys enjoyed this video. It's a pretty short video, but uh, yeah, that's it. Peace