답안 #22675

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
22675 2017-04-30T06:26:26 Z 삼*전자 그린픽스(#986, pichulia) hi (KRIII5_HI) C++
0 / 7
3 ms 1256 KB
#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

HI.cpp: In function 'long long int dp_small(int, int)':
HI.cpp:10:9: warning: unused variable 'j' [-Wunused-variable]
  int i, j, k;
         ^
HI.cpp: In function 'int main()':
HI.cpp:70:15: warning: unused variable 'l' [-Wunused-variable]
  int i, j, k, l;
               ^
HI.cpp:71:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
                 ^
HI.cpp:73:21: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &a[i]);
                     ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 1256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 1256 KB Output isn't correct
2 Halted 0 ms 0 KB -