scala oneliner
scala []\nobject Solution {\n  import scala.util.chaining._\n  def countPairs(nums: Array[Int], k: Int): Long =\n    nums.toList.groupMapReduce(num => (BigInt(n
```scala []\nobject Solution {\n  import scala.util.chaining._\n  def countPairs(nums: Array[Int], k: Int): Long =\n    nums.toList.groupMapReduce(num => (BigInt(num) gcd k).toLong)(_ => 1L)(_ + _)\n      .pipe { cnts =>\n        (for {a <- cnts.keysIterator; b <- cnts.keysIterator; if a <= b && a * b % k == 0} yield {\n          if (a == b) cnts(a) * (cnts(a) - 1) / 2 else cnts(a) * cnts(b)\n        }).sum\n      }\n}\n```
['Hash Table', 'Scala']