Calculate LCM of N numbers modulo 1000000007

后端 未结 4 1574
没有蜡笔的小新
没有蜡笔的小新 2020-12-22 03:32

I was solving following problem on LCM : Calculate LCM of N numbers modulo 1000000007

My approach :

typedef unsigned long long ull;
         


        
4条回答
  •  心在旅途
    2020-12-22 03:46

    The correct approach would be to prime factorize the elements of the array and keep track of the highest power of every prime for each element. LCM will be the product of these primes raised to their highest power in the array.

提交回复
热议问题