Advertisement
BeiZero

Untitled

Apr 2nd, 2015
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 1.00 KB | None | 0 0
  1. object Solve extends App with fastIO{
  2.   val (n,k) = (nextInt,nextInt)
  3.   def P(x:Long) = (132*x*x*x+77*x*x+1345*x+1577) % 1743
  4.   print(1 to n map ((x)=>P(x).toInt) sortWith (_<_) apply (k-1))
  5.   flush
  6. }
  7.  
  8. trait fastIO {
  9.   import java.io._
  10.   val isFile = true
  11.   val input = "kth.in"
  12.   val output = "kth.out"
  13.   val in = new StreamTokenizer(new BufferedReader(if(isFile) new FileReader(input) else new InputStreamReader(System.in)))
  14.   val out = new PrintWriter(if(isFile)new FileWriter(output) else new OutputStreamWriter(System.out))
  15.   def next: String = {
  16.     in.ordinaryChars('0', '9')
  17.     in.wordChars('0', '9')
  18.     in.nextToken()
  19.     in.sval
  20.   }
  21.   def nextInt: Int = {
  22.     in.nextToken()
  23.     in.nval.toInt
  24.   }
  25.   def nextLong:Long ={
  26.     in.nextToken()
  27.     in.nval.toLong
  28.   }
  29.   def nextDouble: Double = {
  30.     in.nextToken()
  31.     in.nval
  32.   }
  33.   def println(o:Any) = out.println(o)
  34.   def print(o:Any) = out.print(o)
  35.   def printf(s:String,o:Any*) = out.printf(s,o)
  36.   def flush() = out.flush()
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement