# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
22675 | 삼*전자 그린픽스 (#40) | hi (KRIII5_HI) | C++98 | 3 ms | 1256 KiB |
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<stdio.h>
#define M 1000000007
int n;
int a[109];
int dx[6] = { 1,1,0,-1,-1,0 };
long long int dd[109][109];
int rr[109][109];
long long int dp_small(int p, int q)
{
int i, j, k;
if (p < q) { k = p; p = q; q = k; }
if (q < 0)return 0;
if (rr[p][q]) return dd[p][q];
rr[p][q] = 1;
if (q == 0)return dd[p][q] = p;
long long int res = 0;
for (i = 0; i < p; i++) {
k = i % 6;
if (dx[k] == 1) {
res = (res + dp_small(p - i - 1, q)) % M;
}
else if (dx[k] == -1) {
res = (res - dp_small(p - i - 1, q) + M) % M;
}
}
for (i = 0; i < q; i++) {
k = i % 6;
if (dx[k] == 1) {
res = (res + dp_small(q - i - 1, p)) % M;
}
else if (dx[k] == -1) {
res = (res - dp_small(q - i - 1, p) + M) % M;
}
}
return dd[p][q] = res;
}
void process_small() {
long long int res;
res = 0;
int i, j, k;
int p, q;
p = a[0];
q = a[1];
for (i = 0; i < p; i++) {
for (j = 0; j <= p - i; j++) {
k = (i + j) % 6;
if (dx[k] == 1) {
res = (res + dp_small(p - (i + j + 1), q)) % M;
}
else if (dx[k] == -1) {
res = (res + dp_small(p - (i + j + 1), q)) % M;
}
}
}
for (i = 0; i < q; i++) {
for (j = 0; j <= q - i; j++) {
k = (i + j) % 6;
if (dx[k] == 1) {
res = (res + dp_small(q - (i + j + 1), p)) % M;
}
else if (dx[k] == -1) {
res = (res + dp_small(q - (i + j + 1), p)) % M;
}
}
}
printf("%lld\n", res);
}
int main() {
int i, j, k, l;
scanf("%d", &n);
for (i = 0; i < n; i++) {
scanf("%d", &a[i]);
}
for (i = 0; i < n; i++) {
for (j = i+1; j < n; j++) {
if (a[i] < a[j])
{
k = a[i];
a[i] = a[j];
a[j] = k;
}
}
}
if (a[1] == 0) {
printf("%d\n", a[0]);
return 0;
}
process_small();
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |