I am looking at the following piece of code in Java:
public class MyClass {
public static void main(String args[]) {
int mod = (int) (1e9) + 7;
int curValue = 483575207;
int numFullRow = 237971068;
long profit1 = 995913967;
long profit2 = profit1;
int numSameColor = 3;
profit1 %= mod;
profit2 %= mod;
profit1 += (long)(curValue + curValue - numFullRow + 1) * numFullRow / 2 * numSameColor;
System.out.println(profit1 % mod);
profit2 += ((long)(curValue + curValue - numFullRow + 1) *numFullRow / 2 * numSameColor) % mod;
System.out.println(profit2);
}
}
The output of profit1
and profit2
turned out to be different which I do not quite understand. profit2
does not work as expected.