while attempting the question in this link

I could not find an approach for finding (a*b)%c where a*b exceeds the range of long long in in C.

So, I searched and found this in someone’s solution :

typedef long double LD;

typedef long long LL;

LL big_mult(LL a,LL b,LL mod){

```
LD ans;
LL c;
a=a%mod;
b=b%mod;
ans=(LD)a*b;
a=a*b;
c=(LL)(ans/mod);
a=a-c*mod;
a=a%mod;
if(a<0)
a=a+mod;
return a;
```

}

How can we validate this logic when a*b exceeds the range of long long ?