This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "hexagon.h"
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
long long pw(long long x, long long n) {
long long res = 1;
while (n > 0) {
if (n & 1) {
res = res * x % mod;
}
n /= 2;
x = x * x % mod;
}
return res;
}
int draw_territory(int N, int A, int B,
std::vector<int> D, std::vector<int> L) {
long long X, Y;
if (N == 3) {
assert (L[0] == L[1]);
assert (L[1] == L[2]);
long long x = L[0] + 1;
X = x * (x + 1) / 2;
Y = x * (x + 1) % mod * (2 * x + 1) % mod * pw(6, mod - 2) - X;
} else {
X = 0;
Y = 0;
}
X %= mod;
Y %= mod;
long long res = X * A % mod + Y * B % mod;
res = (res % mod + mod) % mod;
return res;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |