Test instructions: Give m*n grid, K person, request first row, last row, first column and last column must be someone.
Thinking: It is difficult to reverse, consider the first line, the last line, the first column and the last column are not up to the requirements of the situation. Sum=sum1-a-b-c-d+ab+ac+ad+bc+bd+cd-abc-abd-acd-bcd+abcd. SUM1 is expressed in 0. A,b,c,d with 1,2,4,8, for example: 1&i if not 0 means I contains a set. Example: 11 (1011) contains 8,2,1, or D,b,a.
Rujia Code:
#include <iostream>#include<cstring>using namespacestd;Const intMod=1000007;Const intmaxk= -;intc[maxk+Ten][maxk+Ten];intMain () {memset (C,0,sizeof(C)); c[0][0]=1; for(intI=0; i<=maxk;i++) {c[i][0]=c[i][i]=1; for(intj=1; j<i;j++) C[i][j]= (c[i-1][j]+c[i-1][j-1])%MOD; } intT; scanf ("%d",&T); for(intKase=1; kase<=t;kase++) { intn,m,k,sum=0; scanf ("%d%d%d",&n,&m,&k); for(ints=0;s< -; s++) { intb=0, r=n,c=m; if(s&1) {r--;b++;} if(s&2) {r--;b++;} if(s&4) {c--;b++;} if(s&8) {c--;b++;} if(b&1) sum= (Sum+mod-c[r*c][k])%MOD; ElseSum= (Sum+c[r*c][k])%MOD; } printf ("Case %d:%d\n", kase,sum); } return 0;}
Uva11806cheerleaders principle of tolerance, binary system