Cheerleaders
Description
 

C

Cheerleaders

In most professional sporting events, cheerleaders play a major role in entertaining the spectators. Their roles are substantial during breaks and prior to start of play. The world cup soccer is no exception. Usually the cheerleaders form a group and perform at the centre of the field. In addition to this group, some of them are placed outside the side line so they are closer to the spectators. The organizers would like to ensure that at least one cheerleader is located on each of the four sides. For this problem, we will model the playing ground as an M*N rectangular grid. The constraints for placing cheerleaders are described below:

  • There should be at least one cheerleader on each of the four sides. Note that, placing a cheerleader on a corner cell would cover two sides simultaneously.
  • There can be at most one cheerleader in a cell.
  • All the cheerleaders available must be assigned to a cell. That is, none of them can be left out.

The organizers would like to know, how many ways they can place the cheerleaders while maintaining the above constraints. Two placements are different, if there is at least one cell which contains a cheerleader in one of the placement but not in the other.

 

Input

 

The first line of input contains a positive integer T<=50, which denotes the number of test cases. T lines then follow each describing one test case. Each case consists of three nonnegative integers, 2<=M, N<=20 and K<=500. Here M is the number of rows and N is the number of columns in the grid. K denotes the number of cheerleaders that must be assigned to the cells in the grid.

 

 

Output

For each case of input, there will be one line of output. It will first contain the case number followed by the number of ways to place the cheerleaders as described earlier. Look at the sample output for exact formatting. Note that, the numbers can be arbitrarily large. Therefore you must output the answers modulo1000007.

Sample Input

Sample Output

2

2 2 1

2 3 2

Case 1: 0

Case 2: 2

 

k个石头放到  n*m 的矩阵 , 在4条边上一定要有石头有多少种方法 ?

用容斥来加加减减...

集合A表示第一行没石头...集合B表示第二行没有石头.. D..C如痴类推。

0 ~ 1<<16-1 表示出所有集合..

当我们加上全集的时候,,,要剪一个除了A的集合,,,但是少剪了除了B的集合..

若果剪了除了B的集合...我们多减了同时出去A.B情况的集合..这个时候要加回来..

思想大概如此

#include <bits/stdc++.h>
using namespace std;
unsigned long long C[][];
const int mod = ; void run()
{ unsigned long long ans = , n , m , k ;
cin >> n >> m >> k ;
for( int s = ; s < ; ++s ){
int b = , r = n ,c = m ;
if( s& ){ r-- ; b++ ;}
if( s& ){ r-- ; b++ ;}
if( s& ){ c-- ; b++ ;}
if( s& ){ c-- ; b++ ;}
if( b& ) ans = ( ans + mod - C[r*c][k] ) %mod ;
else ans = ( ans + C[r*c][k] )%mod;
}
cout << ans << endl;
}
int main()
{
#ifdef LOCAL
freopen("in.txt","r",stdin);
#endif
for( int i = ; i <= ; ++i ){
C[i][] = C[i][i] = ;
for( int j = ; j < i ; ++j ){
C[i][j] = ( C[i-][j] + C[i-][j-] ) % mod ;
}
}
int cas = , _ ; cin >> _ ;
while( _-- ) { cout << "Case "<< cas++ <<": "; run(); }
}

最新文章

  1. C#中Finally的一个不太常见的用法
  2. Laravel RuntimeException inEncrypter.php line 43: The only supported ciphers are AES-128-CBC and AES-256-CBC with the correct key lengths
  3. MySQL的数值类型,时间
  4. css3效果
  5. go tool proof
  6. GFS Google File System(中文翻译)
  7. oc-22-sel
  8. Android原型界面设计工具
  9. AOP 面向方面的编程 Aspect Oriented Programing --第一次听说呢,汗!
  10. 当JAVA集合移除自身集合元素时发生的诸多问题
  11. C文件操作的语言fgets()
  12. 2301: [HAOI2011]Problem b ( 分块+莫比乌斯反演+容斥)
  13. Android WebView编程的那些坑(一)
  14. 转://oracle 11G+ASM for Linux手工建库
  15. MonkeyRunner_模拟机_运行脚本
  16. 利用mvn deploy命令上传包(转)
  17. Redis 实现消息队列 MQ
  18. 【cs229-Lecture13】高斯混合模型
  19. perl6 HTTP::UserAgent发送post
  20. Python下opencv使用笔记(图像的平滑与滤波)

热门文章

  1. BZOJ 4765(分块+树状数组)
  2. subprocess 模块 与 re 模块
  3. java虚拟机规范(se8)——class文件格式(一)
  4. console.log的另一种用法
  5. redux 介绍及配合 react开发
  6. Spring MVC 配置Controller详解
  7. 前端学习(三十)es6的一些问题(笔记)
  8. 离线安装gcc_rpm(centos下安装gcc的方法之一)
  9. redis单节点安装及cluster的安装
  10. cocos2D-X not config ndk path