답안 #3889

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
3889 2013-08-31T09:09:23 Z pichulia Hexagon travel (kriii1_H) C++
1 / 1
100 ms 1168 KB
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<algorithm>
#include<vector>

#define M 1000000007
using namespace::std;

int rr[5100];
int gg[5100];
int bb[5100];
int dd[5100];
int a,b,c;


void input()
{
	scanf("%d %d %d",&a,&b,&c);
}
long long int acb(int x,int y)
{
	int i, j;
	int n = x+y;
	dd[0] = 1;
	for(i=0; i<n; i++)
	{
		dd[0] = 1;
		for(j=i+1; j>0; j--)
		{
			dd[j] = (dd[j]+dd[j-1])%M;
		}
	}
	return dd[x];
}
void process()
{
	int i, j, k;
	int tr, tg, tb;
	for(k=0; k<=c; k++)
	{
		rr[1] = gg[1] = bb[1] = 0;
		if(k%3==0)
			bb[1] = 1;
		else if(k%3 == 1)
			rr[1] = 1;
		else
			gg[1] = 1;

		for(i=2; i<=a+b+1; i++)
		{
			tr = rr[i];
			tg = gg[i];
			tb = bb[i];
			rr[i] = rr[i-1];
			gg[i] = gg[i-1];
			bb[i] = bb[i-1];

			if(i%2==0)
			{
				rr[i] = (rr[i] + tg)%M;
				gg[i] = (gg[i] + tb)%M;
				bb[i] = (bb[i] + tr)%M;
			}
			else
			{
				rr[i] = (rr[i] + tb)%M;
				gg[i] = (gg[i] + tr)%M;
				bb[i] = (bb[i] + tg)%M;
			}
		}
		/*
		for(i=1; i<=a+b+1; i++,printf("\n"))
				printf("%d %d %d  ",rr[i],gg[i],bb[i]);
		getchar();
		*/
	}
	long long int l = acb(a,b);
	long long int rrr,ggg,bbb;
	rrr = l * rr[a+b+1]; 
	ggg = l * gg[a+b+1];
	bbb = l*bb[a+b+1];
	rrr%=M;
	ggg%=M;bbb%=M;
	printf("%lld\n%lld\n%lld\n",rrr,ggg,bbb);
}

void output()
{
}

int main()
{
	input();
	process();
	output();
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1168 KB Output is correct
2 Correct 0 ms 1168 KB Output is correct
3 Correct 0 ms 1168 KB Output is correct
4 Correct 0 ms 1168 KB Output is correct
5 Correct 0 ms 1168 KB Output is correct
6 Correct 4 ms 1168 KB Output is correct
7 Correct 0 ms 1168 KB Output is correct
8 Correct 0 ms 1168 KB Output is correct
9 Correct 4 ms 1168 KB Output is correct
10 Correct 100 ms 1168 KB Output is correct
11 Correct 56 ms 1168 KB Output is correct
12 Correct 36 ms 1168 KB Output is correct
13 Correct 8 ms 1168 KB Output is correct
14 Correct 24 ms 1168 KB Output is correct
15 Correct 24 ms 1168 KB Output is correct
16 Correct 4 ms 1168 KB Output is correct
17 Correct 36 ms 1168 KB Output is correct
18 Correct 28 ms 1168 KB Output is correct
19 Correct 8 ms 1168 KB Output is correct
20 Correct 12 ms 1168 KB Output is correct