Submission #3889

#TimeUsernameProblemLanguageResultExecution timeMemory
3889pichuliaHexagon travel (kriii1_H)C++98
1 / 1
100 ms1168 KiB
#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; }
#Verdict Execution timeMemoryGrader output
Fetching results...