#include "hexagon.h"
#include <bits/stdc++.h>
template <int md>
struct Modular {
int v;
constexpr Modular() : v(0) {}
template <typename T>
static inline int normalize(const T& x) {
int res = -md <= x && x < md ? static_cast<int>(x) : static_cast<int>(x % md);
return res + (res < 0) * md;
}
static constexpr int mod() {
return md;
}
template <typename U>
Modular(const U& x) : v(normalize(x)) {}
const int& operator()() const { return v; }
template <typename U>
explicit operator U() const {
return static_cast<U>(v);
}
using M = Modular;
constexpr static inline M _raw(int x) {
static_assert(x >= 0 && x < md);
M res;
res.v = x;
return res;
}
template <typename U>
friend std::enable_if_t<std::is_integral_v<U>, M> power(M b, U e) {
assert(e >= 0);
M ans = 1;
while (e) {
if (e & 1) ans *= b;
b *= b;
e >>= 1;
}
return ans;
}
M inv() const {
M res = power(*this, md - 2);
return res;
}
M& operator+=(const M& y) { return v += y.v, v -= (v >= md) * md, *this; }
M& operator-=(const M& y) { return v -= y.v, v += (v < 0) * md, *this; }
M& operator*=(const M& y) { return v = (int64_t) v * y.v % md, *this; }
M& operator/=(const M& y) { return *this *= y.inv(); }
M& operator++() { return *this += _raw(1); }
M& operator--() { return *this -= _raw(1); }
M operator++(int) {
M res(*this);
return *this += _raw(1), res;
}
M operator--(int) {
M res(*this);
return *this -= _raw(1), res;
}
M operator-() const { return M(-v); }
friend bool operator==(const M& x, const M& y) { return x.v == y.v; }
friend bool operator<(const M& x, const M& y) { return x.v < y.v; }
friend bool operator>(const M& x, const M& y) { return x.v > y.v; }
friend bool operator<=(const M& x, const M& y) { return x.v <= y.v; }
friend bool operator>=(const M& x, const M& y) { return x.v >= y.v; }
friend bool operator!=(const M& x, const M& y) { return x.v != y.v; }
template <typename Istream>
friend Istream& operator>>(Istream& is, M& y) {
int64_t x;
is >> x;
y.v = y.normalize(x);
return is;
}
template <typename Ostream>
friend Ostream& operator<<(Ostream& os, const M& y) {
return os << y.v;
}
friend M operator+(const M& x, const M& y) { return M(x) += y; }
friend M operator-(const M& x, const M& y) { return M(x) -= y; }
friend M operator*(const M& x, const M& y) { return M(x) *= y; }
friend M operator/(const M& x, const M& y) { return M(x) /= y; }
};
constexpr int md = 1e9 + 7;
using Mint = Modular<md>;
int draw_territory(int N, int A, int B, std::vector<int> D, std::vector<int> L) {
Mint answer = 0;
// 0 * 1 + 1 * 2 + 2 * 3 + .... (sz - 1) * sz
// S = 0 * 1 + 1 * 2 + .... + (sz - 1) * sz
// S = 1 + 2 + 3 + ... + sz
// sum squares - sum normal
// 1^2 + 2^2 + ...
// f(n - 1) + n^2
// f(0) = 0
// n * (n + 1) *()
Mint size = L[0];
answer = size * (size + 1) * (size * 2 + 1) / 6;
answer -= size * (size + 1) / 2;
return (int) answer;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
500 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |