Advertisement
Guest User

Untitled

a guest
Oct 9th, 2015
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. package Main
  2.  
  3. import java.io.{FileOutputStream, FileInputStream}
  4.  
  5. import scala.io.StdIn
  6.  
  7.  
  8. object Main extends App {
  9. Console.setIn(new FileInputStream("example.in"))
  10.  
  11. Console.setIn(new FileInputStream("B-large-practice.in"))
  12. Console.setOut(new FileOutputStream("B-large-practice.out"))
  13.  
  14. def solve(li:Int, ri:Int, ai:Array[Int]):Double = {
  15. Math.exp(ai.slice(li, ri + 1).map(Math.log(_)).sum / (ri - li + 1))
  16. }
  17.  
  18. val cases = StdIn.readLine().toInt
  19. (1 to cases) foreach { n =>
  20. val Array(_, m) = StdIn.readLine().split(" ").map(_.toInt)
  21. val ai = StdIn.readLine().split(" ").map(_.toInt)
  22. println(s"Case #$n:")
  23. (1 to m) foreach ( v => {
  24. val Array(li, ri) = StdIn.readLine().split(" ").map(_.toInt)
  25. println(solve(li, ri, ai))
  26. })
  27. }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement