Skip to content

Commit ba60030

Browse files
committed
feat: add solutions to lc problem: No.1716
No.1716.Calculate Money in Leetcode Bank
1 parent 75748ea commit ba60030

File tree

9 files changed

+90
-413
lines changed

9 files changed

+90
-413
lines changed

.docsifytopdfrc.js

-7
This file was deleted.

package.json

-3
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,5 @@
55
},
66
"dependencies": {
77
"docsify-cli": "^4.4.3"
8-
},
9-
"devDependencies": {
10-
"docsify-pdf-converter": "^2.0.7"
118
}
129
}

solution/1700-1799/1716.Calculate Money in Leetcode Bank/README.md

+32-1
Original file line numberDiff line numberDiff line change
@@ -47,22 +47,53 @@
4747

4848
<!-- 这里可写通用的实现逻辑 -->
4949

50+
等差数列。
51+
5052
<!-- tabs:start -->
5153

5254
### **Python3**
5355

5456
<!-- 这里可写当前语言的特殊实现逻辑 -->
5557

5658
```python
57-
59+
class Solution:
60+
def totalMoney(self, n: int) -> int:
61+
a, b = divmod(n, 7)
62+
return (28 + 28 + 7 * (a - 1)) * a // 2 + (a * 2 + b + 1) * b // 2
5863
```
5964

6065
### **Java**
6166

6267
<!-- 这里可写当前语言的特殊实现逻辑 -->
6368

6469
```java
70+
class Solution {
71+
public int totalMoney(int n) {
72+
int a = n / 7, b = n % 7;
73+
return (28 + 28 + 7 * (a - 1)) * a / 2 + (a * 2 + b + 1) * b / 2;
74+
}
75+
}
76+
```
77+
78+
### **C++**
79+
80+
```cpp
81+
class Solution {
82+
public:
83+
int totalMoney(int n) {
84+
int a = n / 7, b = n % 7;
85+
return (28 + 28 + 7 * (a - 1)) * a / 2 + (a * 2 + b + 1) * b / 2;
86+
}
87+
};
88+
```
89+
90+
### **Go**
6591
92+
```go
93+
func totalMoney(n int) int {
94+
a, b := n/7, n%7
95+
return (28+28+7*(a-1))*a/2 + (a*2+b+1)*b/2
96+
}
6697
```
6798

6899
### **...**

solution/1700-1799/1716.Calculate Money in Leetcode Bank/README_EN.md

+30-1
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,42 @@
4949
### **Python3**
5050

5151
```python
52-
52+
class Solution:
53+
def totalMoney(self, n: int) -> int:
54+
a, b = divmod(n, 7)
55+
return (28 + 28 + 7 * (a - 1)) * a // 2 + (a * 2 + b + 1) * b // 2
5356
```
5457

5558
### **Java**
5659

5760
```java
61+
class Solution {
62+
public int totalMoney(int n) {
63+
int a = n / 7, b = n % 7;
64+
return (28 + 28 + 7 * (a - 1)) * a / 2 + (a * 2 + b + 1) * b / 2;
65+
}
66+
}
67+
```
68+
69+
### **C++**
70+
71+
```cpp
72+
class Solution {
73+
public:
74+
int totalMoney(int n) {
75+
int a = n / 7, b = n % 7;
76+
return (28 + 28 + 7 * (a - 1)) * a / 2 + (a * 2 + b + 1) * b / 2;
77+
}
78+
};
79+
```
80+
81+
### **Go**
5882
83+
```go
84+
func totalMoney(n int) int {
85+
a, b := n/7, n%7
86+
return (28+28+7*(a-1))*a/2 + (a*2+b+1)*b/2
87+
}
5988
```
6089

6190
### **...**
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
class Solution {
2+
public:
3+
int totalMoney(int n) {
4+
int a = n / 7, b = n % 7;
5+
return (28 + 28 + 7 * (a - 1)) * a / 2 + (a * 2 + b + 1) * b / 2;
6+
}
7+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
func totalMoney(n int) int {
2+
a, b := n/7, n%7
3+
return (28+28+7*(a-1))*a/2 + (a*2+b+1)*b/2
4+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
class Solution {
2+
public int totalMoney(int n) {
3+
int a = n / 7, b = n % 7;
4+
return (28 + 28 + 7 * (a - 1)) * a / 2 + (a * 2 + b + 1) * b / 2;
5+
}
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
class Solution:
2+
def totalMoney(self, n: int) -> int:
3+
a, b = divmod(n, 7)
4+
return (28 + 28 + 7 * (a - 1)) * a // 2 + (a * 2 + b + 1) * b // 2

0 commit comments

Comments
 (0)