fork(1) download
  1. import scala.collection.immutable.List
  2.  
  3. object Main extends App {
  4.  
  5. def main override (args: Array[String]){
  6. var s = readInt()
  7. var t = readLine()
  8. var p = t.split(' ')
  9. var i = 0
  10. var x = readInt()
  11. var y = List[String]()
  12. for ( i <- 0 until x) {
  13. var cx = readLine()
  14. y :+= cx
  15. }
  16. var arr = new Array[Int](s)
  17. var ar2 = List[Any]()
  18. for (i <- 0 until s){
  19. arr(i) = p(i).toInt
  20. }
  21. for ( i <- 0 until x) {
  22. var u = y(i).split(' ')
  23. if(u(0) == "Q"){
  24. var w1 = u(1).toInt
  25. var w2 = u(2).toInt
  26. var q = arr(w1)
  27. for (i <- w1 until w2){
  28. if ((i+1) <= w2){
  29. var g = lcm(q,arr(i+1));
  30. q = g;
  31. }
  32.  
  33. }
  34. ar2 :+= q
  35. }
  36. if(u(0) == "U"){
  37. var w1 = u(1).toInt
  38. var w2 = u(2).toInt
  39. arr(w1) = (arr(w1) * w2)
  40. }
  41. }
  42.  
  43. for (i <- ar2){
  44. println(i)
  45. }
  46. }
  47.  
  48. def gcd(a: Int, b: Int):Int=if (b==0) a.abs else gcd(b, a%b)
  49.  
  50. def lcm(a: Int, b: Int):Int=(a*b).abs/gcd(a,b)
  51.  
  52. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
5
2 5 6 1 9
7
Q 0 4
U 1 2
Q 0 2
Q 3 4
Q 2 4
U 3 8
Q 2 3
compilation info
/opt/scala/bin/scalac: line 50: /dev/null: Permission denied
Main.scala:5: error: '=' expected but 'override' found.
	def main override (args: Array[String]){
                 ^
Main.scala:48: error: illegal start of simple expression
	def gcd(a: Int, b: Int):Int=if (b==0) a.abs else gcd(b, a%b)
^
two errors found
spoj: The program compiled successfully, but Main.class was not found.
      Class Main should contain method: def main(args: Array[String]).
stdout
Standard output is empty