#include "hexagon.h"
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int dx[] = {-1, 0, 1, 1, 0, -1};
int dy[] = {0, 1, 1, 0, -1, -1};
ll n, A, B;
const int MOD = 1e9 + 7;
ll power(ll a, ll b, ll p) {
ll res = 1;
while(b > 0) {
if (b & 1) res = res * a % p;
a = a * a % p;
b /= 2;
}
return res;
}
ll inv(ll a, ll p) {
return power(a, p-2, p);
}
int draw_territory(int _n, int _A, int _B, std::vector<int> d, std::vector<int> l) {
n = _n;
A = _A;
B = _B;
if (n == 3) {
ll x = l[0]+1;
if (l[0] != l[1] || l[1] != l[2]) x = x / (x - x);
ll res = (
( (x+1) * (x) / 2 % MOD * A % MOD) +
(B *
(
(x * (x+1) / 2) % MOD +
x * (x + 1) % MOD * (2*x + 1) % MOD * inv(6, MOD) %MOD
) % MOD
) % MOD
)%MOD;
return (res % MOD + MOD) % MOD;
}
return 0;
}
Compilation message
hexagon.cpp: In function 'int draw_territory(int, int, int, std::vector<int>, std::vector<int>)':
hexagon.cpp:29:49: warning: division by zero [-Wdiv-by-zero]
29 | if (l[0] != l[1] || l[1] != l[2]) x = x / (x - x);
| ~~^~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |