This problem is kind of like a combinatorics type of problem, I believe. But also has the feeling that it kind of makes use of the so-called "pigeonhole principle". I recall doing a problem like this many years ago in University in a Discrete Mathematics course.
See problem below:
For the part of this problem, where any 7 caves in a row contains exactly 77 bats. I just did simple algebra of 7K =77, and got K = 11 bats in each cave. It satisfies the condition that there has to be at least 2 bats in every cave. But I am getting confused as to how to handle the very beginning and very last of the caves. Hope someone can provide some clarity on this.

the numbers in each cave must repeat with a period of 7, so cave 1 has the same number as cave 43 and cave 3 the same as cave 45.
Also caves 4 to 45 contain a total of $6 \times 77 = 462$ bats