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(); }
}

UVA 10806 Cheerleaders的更多相关文章

  1. uva 11806 Cheerleaders

    // uva 11806 Cheerleaders // // 题目大意: // // 给你n * m的矩形格子,要求放k个相同的石子,使得矩形的第一行 // 第一列,最后一行,最后一列都必须有石子. ...

  2. UVA.11806 Cheerleaders (组合数学 容斥原理 二进制枚举)

    UVA.11806 Cheerleaders (组合数学 容斥原理 二进制枚举) 题意分析 给出n*m的矩形格子,给出k个点,每个格子里面可以放一个点.现在要求格子的最外围一圈的每行每列,至少要放一个 ...

  3. uva 10806 Dijkstra, Dijkstra. (最小费最大流)

    uva 10806 Dijkstra, Dijkstra. 题目大意:你和你的伙伴想要越狱.你的伙伴先去探路,等你的伙伴到火车站后,他会打电话给你(电话是藏在蛋糕里带进来的),然后你就能够跑去火车站了 ...

  4. Uva 10806 来回最短路,不重复,MCMF

    题目链接:https://uva.onlinejudge.org/external/108/10806.pdf 题意:无向图,从1到n来回的最短路,不走重复路. 分析:可以考虑为1到n的流量为2时的最 ...

  5. UVA 11806 Cheerleaders dp+容斥

    In most professional sporting events, cheerleaders play a major role in entertaining the spectators. ...

  6. UVa 11806 Cheerleaders (容斥原理+二进制表示状态)

    In most professional sporting events, cheerleaders play a major role in entertaining the spectators. ...

  7. uva 11806 Cheerleaders (容斥)

    http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&p ...

  8. UVa 10806 & 费用流+意识流...

    题意: 一张无向图,求两条没有重复的从S到T的路径. SOL: 网络流为什么屌呢..因为网络流的容量,流量,费用能对许许多多的问题进行相应的转化,然后它就非常的屌. 对于这道题呢,不是要没有重复吗?不 ...

  9. UVA 11806 Cheerleaders (组合+容斥原理)

    自己写的代码: #include <iostream> #include <stdio.h> #include <string.h> /* 题意:相当于在一个m*n ...

随机推荐

  1. Jmeter接口测试加解密及Bean Shell使用案例

    Jmeter接口测试加解密及Bean Shell使用案例 https://blog.csdn.net/russ44/article/details/56009084 本文以base64加解密为例: 一 ...

  2. django中动态生成二级菜单

    一.动态显示二级菜单 1.修改权限表结构 (1)分析需求,要求左侧菜单如下显示: 客户管理: 客户列表 账单管理: 账单列表 (2)修改rbac下的models.py,修改后代码如下: from dj ...

  3. oldlinux

    http://oldlinux.org/Linux.old/ http://oldlinux.org/Book-Lite/

  4. Windows 命令提示符

    命令提示符(cmd): 启动:Win+R ,输入cmd回车 切换盘符:盘符名称: 进入文件夹:cd 文件夹名称 进入多级文件夹:cd 文件夹1\文件夹2\文件夹3 返回上一级:cd .. 直接回根路径 ...

  5. 转帖 Java生成和操作Excel文件

    JAVA EXCEL API:是一开放源码项目,通过它Java开发人员可以读取Excel文件的内容.创建新的Excel文件.更新已经存在的Excel文件.使用该API非Windows操作系统也可以通过 ...

  6. 0xC0000005: 写入位置 0x00000000 时发生访问冲突的解决办法(转)

    上面的意识就是你吧值付给了不该赋给的变量,或者说你把值付给了不能付给的变量(或者常量) ()最简单也最直接的错误可能就是scanf()的问题,我们都知道输入的时候都是scanf("%格式&q ...

  7. 【串线篇】SQL映射文件delete/ insert/ update标签

    一. <insert id="insertEmployee"> INSERT INTO t_employee(empname,gender,email) VALUES( ...

  8. fiddler 4 抓取 https 设置

    Fiddler抓取https 设置 1.打开fiddler,点击工具栏中的Tools—>Options,点击Actions,选择最后一项,Reset All certificates,然后关闭, ...

  9. laravel5.6 基于redis,使用消息队列(邮件推送)

    邮件发送如何配置参考:https://www.cnblogs.com/clubs/p/10640682.html 用到的用户表: CREATE TABLE `recruit_users` ( `id` ...

  10. SCP:从Linux服务器下载文件夹到本地

    原文链接:https://blog.csdn.net/netlai/article/details/79756279 scp /home/work/source.txt work@192.168.0. ...