Skip to content

Commit

Permalink
Create 1716. Calculate Money in Leetcode Bank
Browse files Browse the repository at this point in the history
  • Loading branch information
Chayandas07 authored Dec 6, 2023
1 parent 19517d3 commit 08cf1c5
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions 1716. Calculate Money in Leetcode Bank
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#pragma GCC optimize("O3", "unroll-loops")
class Solution {
public:
int totalMoney(int n) {
auto [q, r]=div(n, 7);
return 28*q+7*q*(q-1)/2+(2*q+r+1)*r/2;
}
};
auto init = []()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
return 'c';
}();

0 comments on commit 08cf1c5

Please sign in to comment.