Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- object Solve extends App with fastIO{
- val (n,k) = (nextInt,nextInt)
- def P(x:Long) = (132*x*x*x+77*x*x+1345*x+1577) % 1743
- print(1 to n map ((x)=>P(x).toInt) sortWith (_<_) apply (k-1))
- flush
- }
- trait fastIO {
- import java.io._
- val isFile = true
- val input = "kth.in"
- val output = "kth.out"
- val in = new StreamTokenizer(new BufferedReader(if(isFile) new FileReader(input) else new InputStreamReader(System.in)))
- val out = new PrintWriter(if(isFile)new FileWriter(output) else new OutputStreamWriter(System.out))
- def next: String = {
- in.ordinaryChars('0', '9')
- in.wordChars('0', '9')
- in.nextToken()
- in.sval
- }
- def nextInt: Int = {
- in.nextToken()
- in.nval.toInt
- }
- def nextLong:Long ={
- in.nextToken()
- in.nval.toLong
- }
- def nextDouble: Double = {
- in.nextToken()
- in.nval
- }
- def println(o:Any) = out.println(o)
- def print(o:Any) = out.print(o)
- def printf(s:String,o:Any*) = out.printf(s,o)
- def flush() = out.flush()
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement