You are viewing a single comment's thread. Return to all comments →
Hello,
For me the same solution is passing in python but failing in Scala, can someone help me debug it?
if((n-2)%2==1): y=((((k-1)**(n-2-1))-1))//k if (x == 1): ways = ((y + 1)*(k-1))+((((k-1)*y))*(k-2)) else: ways=((((k-1)*y) + 1)*(k-2))+((y)*(k-1)) else: y = ((((k - 1) ** (n - 2 - 1)) + 1)) // k if (x == 1): ways = ((y - 1)*(k-1))+(((k-1)*y)*(k-2)) else: ways=((((k-1)*y) - 1)*(k-2))+((y)*(k-1))
if (n % 2 == 1) { val y = (scala.math.pow(k - 1, n - 3).toLong - 1) / k if (x == 1) { ((y + 1) * (k - 1)) + ((k - 1) * y * (k - 2)) } else { ((((k - 1) * y) + 1) * (k - 2)) + (y * (k - 1)) } } else { val y = (scala.math.pow(k - 1, n - 3).toLong + 1) / k if (x == 1) { ((y - 1) * (k - 1)) + ((k - 1) * y * (k - 2)) } else { ((((k - 1) * y) - 1) * (k - 2)) + (y * (k - 1)) } } % div
Seems like cookies are disabled on this browser, please enable them to open this website
Construct the Array
You are viewing a single comment's thread. Return to all comments →
Hello,
For me the same solution is passing in python but failing in Scala, can someone help me debug it?