Use When we have to generate large number of prime Numbers Click Here!
divide by their gcd's to prevent overflow
Find Area of triangle using Side length Heron's Formula.
Area = √(P(P−A)(P−B)(P−C) ) where P is semi perimeter
(ab)%p = ((a%p)*(b%p))%p Use this to compute large modulos like a^n
gcd(a,b)=gcd(a,b%a) Let X=gcd(a,b) then gcd(X/a,X/b)=1
gcd(a,b)=gcd(a,b%a) Let X=gcd(a,b) then gcd(X/a,X/b)=1
To find number of bits required to represent a number : $$ \lfloor {\log_2{n}} \rfloor + 1$$
for (int i = 2; i * 1ll * i <= x; ++i) {
if (x % i == 0) {
dd.push_back(i);
if (i != x / i) {
dd.push_back(x / i);
}
}
}
ll NcR(ll n, ll r)
{
ll p = 1, k = 1;
if (n - r < r)
r = n - r;
if (r != 0) {
while (r) {
p *= n;
k *= r;
ll m = __gcd(p, k);
p /= m;
k /= m;
n--;
r--;
}
}
else
p = 1;
return p;
}