Re: [闲聊] 每日leetcode

楼主: sixB (6B)   2024-07-08 01:50:31
1518.
好怀念喔
这不是小时候的经典数学题吗
像是那个鸡免同笼种树剪绳子什么的
// nb for numBottles, ne for numExchange
once operation:
minus ne bottle would return 1 back
so after one op. the bottles number becomes
nb -(ne-1);
however, there would be some side cases
that just need one more bottle so that it
could reach ne to do one more op.
which means we want
nb -ne than +1,
not nb +1 first, and than -ne
so we let nb -1 first than -(ne-1)
the results simply equals to nb -ne
do the op multiple times:
(nb -1) -(ne -1) -(ne -1) …
the missing bottle we -1 first would finally return
since ne >= 2, we can just throw the final bottle away :)
简单来说
反正喝酒变成尿 不如当初就喝尿
赚钱来花 吃屎来拉
对ㄚ
: : 一行的数学姐看不懂
: : 有大师能用姆咪也看得懂的方式解释一下吗
作者: Smallsh (Smallsh)   2024-07-08 01:51:00
大师
楼主: sixB (6B)   2024-07-08 01:53:00
我根本看不懂我在打什么 吗的
作者: oin1104 (是oin的说)   2024-07-08 01:56:00
屎尿厨

Links booklink

Contact Us: admin [ a t ] ucptt.com