leetcodeSolution to some Leetcode problems written in C++ |
git clone git://git.dimitrijedobrota.com/leetcode.git |
Log | Files | Refs | README | LICENSE |
1716.cpp (263B)
0 class Solution { 1 public: 2 int totalMoney(int n) { 3 const int whole = n / 7, rest = n % 7; 4 int res = whole * (7 * whole + 49) / 2; 5 6 for (int i = 1; i <= rest; i++) { 7 res += whole + i; 8 } 9 10 return res; 11 } 12 };