Skip to content

Commit 88269d1

Browse files
committed
modify code
1 parent d3e0308 commit 88269d1

File tree

4 files changed

+18
-4
lines changed

4 files changed

+18
-4
lines changed

src/class098/Code02_FibonacciNumber.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@ public static int fib2(int n) {
3131
if (n == 1) {
3232
return 1;
3333
}
34-
int[][] base = { { 1, 1 }, { 1, 0 } };
34+
int[][] base = {
35+
{ 1, 1 },
36+
{ 1, 0 }
37+
};
3538
int[][] m = power(base, n - 1);
3639
return m[0][0];
3740
}

src/class098/Code03_ClimbingStairs.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ public static int climbStairs(int n) {
1717
if (n == 1) {
1818
return 1;
1919
}
20-
int[][] base = { { 1, 1 }, { 1, 0 } };
20+
int[][] base = {
21+
{ 1, 1 },
22+
{ 1, 0 }
23+
};
2124
int[][] m = power(base, n - 1);
2225
return m[0][0] + m[1][0];
2326
}

src/class098/Code04_TribonacciNumber.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@ public static int tribonacci(int n) {
1919
if (n == 2) {
2020
return 1;
2121
}
22-
int[][] base = { { 1, 1, 0 }, { 1, 0, 1 }, { 1, 0, 0 } };
22+
int[][] base = {
23+
{ 1, 1, 0 },
24+
{ 1, 0, 1 },
25+
{ 1, 0, 0 }
26+
};
2327
int[][] m = power(base, n - 2);
2428
return m[0][0] + m[1][0];
2529
}

src/class098/Code05_DominoTromino.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,11 @@ public static int f2(int n) {
5454
if (n == 2) {
5555
return 5;
5656
}
57-
int[][] base = { { 2, 1, 0 }, { 0, 0, 1 }, { 1, 0, 0 } };
57+
int[][] base = {
58+
{ 2, 1, 0 },
59+
{ 0, 0, 1 },
60+
{ 1, 0, 0 }
61+
};
5862
int[][] m = power(base, n - 2);
5963
long ans = 5L * m[0][0] % MOD;
6064
ans = (ans + 2L * m[1][0]) % MOD;

0 commit comments

Comments
 (0)