generated from DavidWesley/clean-node-ts-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1291.ts
30 lines (22 loc) · 852 Bytes
/
1291.ts
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
import { readFileSync } from "node:fs"
import { EOL } from "node:os"
import { stdin } from "node:process"
const input = readFileSync(stdin.fd, { encoding: "utf8" }).split(EOL).map(Number.parseFloat)
const calcGridRegionArea = (r: number): number => {
return Math.pow(r, 2) * (4 - Math.sqrt(3) - (2 * Math.PI) / 3)
}
const calcStripedRegionArea = (r: number): number => {
return Math.pow(r, 2) * (1 - Math.sqrt(3) + Math.PI / 3)
}
const calcDottedRegionArea = (r: number): number => {
return Math.pow(r, 2) * (-4 + 2 * Math.sqrt(3) + Math.PI / 3)
}
function main(): void {
const output: string[] = []
for (const R of input) {
if (Number.isNaN(R)) break
output.push([calcStripedRegionArea(R), calcDottedRegionArea(R), calcGridRegionArea(R)].map((area) => area.toFixed(3)).join(" "))
}
console.log(output.join(EOL))
}
main()