here is my code:
object theater extends App {
val m = readInt
val n = readInt
val a = readInt
val c1 = m/a + (if(m%a == 0) 0 else 1)
val c2 = n/a + (if(n%a == 0) 0 else 1)
print(c1 + c2)
}
But the input format is: 3 integers in the same line. But for 3 integers in one line scala will consider that as a string. How can I read that string and get the 3 values in the 3 separated variables?
You could use the following code which will read a line and use the first 3 whitespace separated tokens as the input. (Expects e.g. “1 2 3” as the input on one line)