fork download
  1. package EAREA
  2.  
  3. import kotlin.math.abs
  4.  
  5. fun main(args: Array<String>) {
  6. if(args.isNotEmpty()) {
  7. System.setIn(java.io.FileInputStream(args[0]))
  8. }
  9. if(args.size >= 2) {
  10. System.setOut(java.io.PrintStream(args[1]))
  11. }
  12.  
  13. val N = readLine()!!.toInt()
  14. require(N in 1..100000)
  15.  
  16. data class Point(val x: Long, val y: Long)
  17. val points = List(N) {
  18. val (x, y) = readLine()!!.split(" ").map{ it.toLong() }
  19. require(abs(x) <= 10000000)
  20. require(abs(y) <= 10000000)
  21. Point(x, y)
  22. }
  23.  
  24. fun expectedAreaTimes8(a: Point, b: Point, c: Point, d: Point, e: Point, f: Point): Long {
  25. return c.x * a.y * -1 + c.x * b.y * -1 + c.y * a.x * 1 + c.y * b.x * 1 + d.x * a.y * -1 + d.x * b.y * -1 + d.y * a.x * 1 + d.y * b.x * 1 + e.x * a.y * 1 + e.x * b.y * 1 + e.x * c.y * -1 + e.x * d.y * -1 + e.y * a.x * -1 + e.y * b.x * -1 + e.y * c.x * 1 + e.y * d.x * 1 + f.x * a.y * 1 + f.x * b.y * 1 + f.x * c.y * -1 + f.x * d.y * -1 + f.y * a.x * -1 + f.y * b.x * -1 + f.y * c.x * 1 + f.y * d.x * 1
  26. }
  27.  
  28. val ansTimesEight = (1 until N-1).map { i -> expectedAreaTimes8(points[0], points[1], points[i], points[i+1], points[i+1], points[(i+2)%N]) }.sum()
  29. print(ansTimesEight / 8)
  30. print(".")
  31. println(ansTimesEight % 8 * 125)
  32.  
  33. require(readLine() == null)
  34. }
Runtime error #stdin #stdout #stderr 0.09s 33848KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Exception in thread "main" kotlin.KotlinNullPointerException
	at EAREA.ProgKt.main(prog.kt:13)