File tree Expand file tree Collapse file tree 3 files changed +28
-3
lines changed Expand file tree Collapse file tree 3 files changed +28
-3
lines changed Original file line number Diff line number Diff line change @@ -45,6 +45,8 @@ Step 2. Add the dependency
45
45
46
46
<summary >展开查看</summary >
47
47
48
+ https://leetcode.cn/problems/ccw6C7/
49
+
48
50
https://leetcode.cn/problems/WhsWhI/
49
51
50
52
https://leetcode.cn/problems/longest-consecutive-sequence/
Original file line number Diff line number Diff line change 1
- import longestConsecutive from "../longest-consecutive-sequence/index.ts" ;
2
-
3
- export default longestConsecutive ;
1
+ import longestConsecutive from "../longest-consecutive-sequence/index.ts" ;
2
+
3
+ export default longestConsecutive ;
Original file line number Diff line number Diff line change
1
+ export default function paintingPlan ( n : number , k : number ) : number {
2
+ if ( k === n * n ) return 1 ;
3
+
4
+ let res = 0 ;
5
+ for ( let a = 0 ; a <= n ; a ++ ) {
6
+ for ( let b = 0 ; b <= n ; b ++ ) {
7
+ if ( a * n + b * ( n - a ) === k ) {
8
+ res += combination ( a , n ) * combination ( b , n ) ;
9
+ }
10
+ }
11
+ }
12
+ return res ;
13
+ }
14
+ export function combination ( m : number , n : number ) : number {
15
+ if ( m === 0 ) return 1 ;
16
+ let num1 = 1 ;
17
+ let num2 = 1 ;
18
+ let num3 = 1 ;
19
+ for ( let i = n ; i > 0 ; i -- ) num1 *= i ;
20
+ for ( let i = m ; i > 0 ; i -- ) num2 *= i ;
21
+ for ( let i = n - m ; i > 0 ; i -- ) num3 *= i ;
22
+ return num1 / ( num2 * num3 ) ;
23
+ }
You can’t perform that action at this time.
0 commit comments