leetcodeSolution to some Leetcode problems written in C++ |
git clone git://git.dimitrijedobrota.com/leetcode.git |
Log | Files | Refs | README | LICENSE |
1954.cpp (460B)
0 class Solution {
1 public:
2 long long minimumPerimeter(const long long neededApples) const {
3 long long low = 1, high = 100000;
4 while (low < high) {
5 const long long mid = (low + high) / 2;
6 const long long count = 4 * mid * mid * mid + 6 * mid * mid + 2 * mid;
7 if (count >= neededApples)
8 high = mid;
9 else
10 low = mid + 1;
11 }
12 return low * 8;
13 }
14 };