You are viewing a single comment's thread. Return to all comments →
Scala solution:
import scala.io.StdIn object Solution extends App { def gcd(x: BigInt, y: BigInt): BigInt = { if (x == 0) y else gcd(y % x, x) } def product(nums: String): BigInt = { nums.split(" ").map(BigInt(_)).product } val f = () => StdIn.readLine() val (_, a, _, b) = (f(), product(f()), f(), product(f())) println(gcd(a, b) % 1000000007) }
Seems like cookies are disabled on this browser, please enable them to open this website
Huge GCD
You are viewing a single comment's thread. Return to all comments →
Scala solution: