File tree 9 files changed +90
-413
lines changed
solution/1700-1799/1716.Calculate Money in Leetcode Bank
9 files changed +90
-413
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change 5
5
},
6
6
"dependencies" : {
7
7
"docsify-cli" : " ^4.4.3"
8
- },
9
- "devDependencies" : {
10
- "docsify-pdf-converter" : " ^2.0.7"
11
8
}
12
9
}
Original file line number Diff line number Diff line change 47
47
48
48
<!-- 这里可写通用的实现逻辑 -->
49
49
50
+ 等差数列。
51
+
50
52
<!-- tabs:start -->
51
53
52
54
### ** Python3**
53
55
54
56
<!-- 这里可写当前语言的特殊实现逻辑 -->
55
57
56
58
``` 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
58
63
```
59
64
60
65
### ** Java**
61
66
62
67
<!-- 这里可写当前语言的特殊实现逻辑 -->
63
68
64
69
``` 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**
65
91
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
+ }
66
97
```
67
98
68
99
### ** ...**
Original file line number Diff line number Diff line change 49
49
### ** Python3**
50
50
51
51
``` 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
53
56
```
54
57
55
58
### ** Java**
56
59
57
60
``` 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**
58
82
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
+ }
59
88
```
60
89
61
90
### ** ...**
Original file line number Diff line number Diff line change
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 number Diff line number Diff line change
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 number Diff line number Diff line change
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 number Diff line number Diff line change
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
You can’t perform that action at this time.
0 commit comments