-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoj3.java
More file actions
73 lines (72 loc) · 1.72 KB
/
Copy pathoj3.java
File metadata and controls
73 lines (72 loc) · 1.72 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
///**
// *
// */
//
///**
// * @author DELL
// * Project Name: Java_learn
// * Class Name: oj3
// * date: 2019年8月31日{time}
// */
//public class oj3 {
//
// /**
// * @param args
// */
// public static int ans=0;
// public static int a[] = new int[20];
// public static int visited[] = new int[20];
//
// public static void dfs(int cur) {
// if(cur > 12) {
// if((a[1] + a[2] == a[3])&&
// (a[4]-a[5]==a[6])&&
// (a[7]*a[8] == a[9])&&
// (a[11]*a[12]==a[10])) {
// ans++;
// return;
// }
// }
// for(int i=1;i<=13;i++) {
// if(visited[i]==0) {
// visited[i] = 1;
// a[cur] = i;
// dfs(cur+1);
// visited[i]=0;
// }
// }
// }
// public static void main(String[] args) {
// // TODO Auto-generated method stub
// dfs(1);
// System.out.println(ans);
// }
//
//}
public class oj3 {
public static int ans=0;
public static int a[]=new int[20];
public static int visited[]=new int[20];
public static void dfs(int cur){
if(cur>12){
if((a[1]+a[2]==a[3])&&
(a[4]-a[5]==a[6])&&
(a[7]*a[8]==a[9])&&
(a[11]*a[12]==a[10]))
ans++;
return;
}
for(int i=1;i<=13;i++){
if(visited[i]==0){
visited[i]=1;
a[cur]=i;
dfs(cur+1);
visited[i]=0;
}
}
}
public static void main(String[] args){
dfs(1);
System.out.println(ans);
}
}