-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcut_stamp.java
More file actions
80 lines (73 loc) · 2.31 KB
/
Copy pathcut_stamp.java
File metadata and controls
80 lines (73 loc) · 2.31 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/**
*
*/
/**
* @author DELL
* Project Name: Java_learn
* Class Name: cut_stamp
* date: 2019年9月1日{time}
*/
public class cut_stamp {
/**
* @param args
*/
public static int count = 0;
public static int cut[] = new int[5];
public static int isVisit[] = new int[5];
public static int b[] = {+1, -1, +5, -5};
public static void main(String[] args) {
// TODO Auto-generated method stub
int stamp[] = new int[12];
for (int i=1, k=1; i <= 12; i++) {
stamp[i-1] = k++;
if(i%4 == 0) {
k++;
}
}
for (int a = 0; a < 12; a++) {
for (int b = a+1; b < 12; b++) {
for (int c = b+1; c < 12; c++) {
for (int d = c+1; d < 12; d++) {
for (int e = d + 1; e < 12; e++) {
cut[0] = stamp[a];
cut[1] = stamp[b];
cut[2] = stamp[c];
cut[3] = stamp[d];
cut[4] = stamp[e];
for(int i = 0; i < 5; i++) {
isVisit[i] = 0;
}
isVisit[0] = 1;
find(0);
int flag = 1;
for(int j = 0; j < 5; j++) {
if (isVisit[j] == 0) {
flag = 0;
break;
}
}
if(flag == 1) {
count++;
}
}
}
}
}
}
System.out.println(count);
}
public static void find(int index) {
for(int i = 0; i < 4; i++) {
int temcut = cut[index] + b[i];
if(temcut < 1 || temcut > 14 || temcut == 5 || temcut == 10) {
continue;
}
for(int k = 0; k < 5; k++) {
if(isVisit[k] == 0 && cut[k] == temcut) {
isVisit[k] = 1;
find(k);
}
}
}
}
}