You are viewing a single comment's thread. Return to all comments →
For C++, we need to use n % mod and inverse modulo to do the division.
n % mod
C++
int mod = 1000000007, imod3 = 333333336; int main() { long long t, n; cin >> t; while (t--) { cin >> n; long long nm = n % mod, n2m = n / 2 % mod; long long res = nm * (nm + 1) % mod * (2 * nm + 1) % mod * imod3 - 1; cout << (res - 2 * n2m * n2m % mod) % mod << endl; } return 0; }
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #28: Number spiral diagonals
You are viewing a single comment's thread. Return to all comments →
For C++, we need to use
n % mod
and inverse modulo to do the division.C++