-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathP10432.java
28 lines (26 loc) · 942 Bytes
/
P10432.java
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
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class P10432 {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String line;
while((line = br.readLine()) != null) {
String[] parts = line.split("\\s+");
if(parts.length != 2) {
return;
}
double r = Double.parseDouble(parts[0]);
int n = Integer.parseInt(parts[1]);
double O = (2*Math.PI)/n;
double singleCircularSegmentArea = 0.5 * (O - Math.sin(O));
//System.err.println(r + " " + n);
//System.err.println("SINGLE AREA: " + singleCircularSegmentArea + ", ALL: " + (n*singleCircularSegmentArea));
double res = (Math.PI-singleCircularSegmentArea*n)*r*r;
//System.err.println("RES: " + res);
long resM = Math.round(res*1000);
System.out.printf("%.3f\n", resM/1000.0);
//System.err.println();
}
}
}