-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAnti11.java
More file actions
57 lines (48 loc) · 1.71 KB
/
Copy pathAnti11.java
File metadata and controls
57 lines (48 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import java.util.Scanner;
public class Anti11 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt(); int test;
for (int i = 0; i < n; i++) {
test = sc.nextInt();
int[] caseZero = new int[test];
int[] caseOne = new int[test];
caseZero[0] = 1;
caseOne[0] = 1;
for (int j = 1; j < test; j++) {
caseZero[j] = (int)((int)((int)(caseZero[j-1] % (Math.pow(10,9)+7)) + (int)(caseOne[j-1] % (Math.pow(10,9)+7))) % (Math.pow(10,9)+7));
caseOne[j] = (int)(caseZero[j-1] % (Math.pow(10,9)+7));
}
int answer = (int)((caseOne[test-1] + caseZero[test-1]) % (Math.pow(10,9)+7));
System.out.println(answer);
}
}
// public static void main(String[] args) {
// Scanner sc = new Scanner(System.in);
// int n = sc.nextInt(); int test;
// for (int i = 0; i < n; i++) {
// test = sc.nextInt();
// int sum = 0;
// sum += caseOne(test) + caseZero(test);
// System.out.println(sum % (10^9+7));
// }
// }
// /**
// * For the case where the binary string starts with a 1
// * @param n length of the binary string
// * @return
// */
// public static int caseOne(int n) {
// if(n == 1) return 1;
// return caseZero(n-1);
// }
// /**
// * For the case where the binary string starts with a 0
// * @param n length of the binary string
// * @return
// */
// public static int caseZero(int n) {
// if(n == 1) return 1;
// return caseOne(n-1) + caseZero(n-1);
// }
}