-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcracksrv.java
More file actions
50 lines (43 loc) · 1.43 KB
/
cracksrv.java
File metadata and controls
50 lines (43 loc) · 1.43 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
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class crack {
public static void crack() throws IOException{
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
int input = Integer.parseInt(reader.readLine());
int i=0;
while (i<input){
int m = Integer.parseInt(reader.readLine());
String k = reader.readLine();
String str="";
String find ="01";
int count =0;
if(m==0){
find = "0";
}
else if (m==1){
find="01";
}
else{
int t1 = 0;
int t2 =1;
int t3;
for (int j=2;j<=m;j++){
find = find + Integer.toString(t1 + t2);
t3=t1;
t1=t2;
t2 = t2+t3;
}}
while (find.indexOf(k)!=-1){
int t = find.indexOf(k);
find = find.substring(t+1);
count=count+1;
}
System.out.println(count);
i++;
}
}
public static void main(String[] args) throws IOException{
crack();
}
}