In one of the programming contest, I was asked to take the Modulo with 1000000007.
Below is the code showing how I tried to achieve it.
#include <stdio.h>
#define ll long long
#define MOD 1000000007
ll getmin(ll a, ll b){return (a<b)?a:b;}
void solve(){
    ll a,b,c,Tv;
    scanf("%lld %lld %lld",&a,&b,&c);
    Tv = ((a%MOD)*(b%MOD)*(c%MOD))%MOD;
    ll sideofcube = getmin(a,getmin(b,c));
    ll numofcube = 0;
    ll smallvol = ((sideofcube%MOD)*(sideofcube%MOD)*(sideofcube%MOD))%MOD;
    numofcube = Tv/smallvol;
    printf("%lld %lld\n",sideofcube,numofcube);
}
int main()
{
    int T;
    scanf("%d",&T);
    while(T--){
        solve();
    }
    return 0;
}
With input
1
1000000000 1000000000 100000000
I get a negative response as
100000000 -1
What is going wrong here? I am taking MOD even before multiplying.
 
     
     
    