Artificial intelligent assistant

Money in the bank The bank has 500 dollars. Two operations are allowed: take 300 dollars from the bank or put 198 dollars into it. These operations can be carried out many times, however, you cannot withdraw more money than what the bank has. What is the maximum amount you can get from the bank and how? So I understand there is some invariant or monovariant here but I'm not too sure what it is. Is the monovariant the total amount of money that you and the bank have? How should i start doing it?/ Thank you

The greatest common divisor of 198 and 300 is 6. So you can write 6 as an integer linear combination of 198 and 300, and clearly any such linear combination is divisible by 6. So you can structure your deposits and withdrawals to extract any multiple of 6. (For example, you can withdraw amounts in multiple of 6 by making 3 deposits followed by 2 withdrawals.) The multiple of 6 closest to 500 is 498, so you can extract that amount.

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy cbfd392ab141703295e82d48fb624644