Skip to content

Commit 5082ff2

Browse files
authored
Merge pull request #8 from AlgorithmWithGod/lkhyun
Lkhyun
2 parents f3daafe + 642d41b commit 5082ff2

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
```java
2+
import java.io.BufferedReader;
3+
import java.io.BufferedWriter;
4+
import java.io.InputStreamReader;
5+
import java.io.OutputStreamWriter;
6+
import java.util.*;
7+
public class Main {
8+
static BufferedReader br;
9+
static BufferedWriter bw;
10+
static int[] comb = new int[8];
11+
static boolean[] visited = new boolean[8];
12+
static int[] points = new int[8];
13+
static int count = 0;
14+
public static void main(String[] args) throws Exception {
15+
br = new BufferedReader(new InputStreamReader(System.in));
16+
bw = new BufferedWriter(new OutputStreamWriter(System.out));
17+
StringTokenizer st = new StringTokenizer(br.readLine());
18+
for(int i=0;i<8;i++){
19+
points[i] = Integer.parseInt(st.nextToken());
20+
}
21+
combination(0);
22+
bw.write(count+"");
23+
bw.flush();
24+
}
25+
public static void combination(int depth){
26+
if(depth==8){
27+
for(int i=0;i<8;i++){
28+
if(omok(i)){return;}
29+
}
30+
count++;
31+
return;
32+
}
33+
34+
for(int j=0;j<8;j++){
35+
if(visited[j]){continue;}
36+
visited[j] = true;
37+
comb[depth] = points[j];
38+
combination(depth+1);
39+
visited[j] = false;
40+
}
41+
}
42+
public static boolean omok(int curpoint){
43+
double prev = (double)comb[(curpoint+7)%8];
44+
double next = (double)comb[(curpoint+1)%8];
45+
double slope = prev/next + 1;
46+
double distance = (prev / slope) * Math.sqrt(2);
47+
if(comb[curpoint] < distance){return true;}
48+
return false;
49+
}
50+
}
51+
```

0 commit comments

Comments
 (0)