UVa 11806 Cheerleaders:组合&逆向思维||容斥定理

11806 - Cheerleaders

Time limit: 2.000 seconds

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

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 modulo 1000007.

【题意】

时间: 2024-08-06 22:15:22

UVa 11806 Cheerleaders:组合&amp;逆向思维||容斥定理的相关文章

uva 11806 - Cheerleaders

点击打开链接 题意:在一个n行m列的矩形里面放k个相同的石子,要求第一行,最后一行,第一列,最后一列都要有石子.问有几种方法? 思路: 1 如果题目没有要求"第一行,最后一行,第一列,最后一列都要有石子",那么答案就是C[n*m][k],我们用C[i][j]表示i个里面选择j个的组合数. 2 设满足"第一行没有石子"的集合为A,"第一列没有石子"的集合为B,"最后一行没有石子"的集合为C,"最后一列没有石子"

codeforces B. Friends and Presents(二分+容斥)

题意:从1....v这些数中找到c1个数不能被x整除,c2个数不能被y整除!并且这c1个数和这c2个数没有相同的!给定c1, c2, x, y, 求最小的v的值! 思路: 二分+容斥,二分找到v的值,那么s1 = v/x是能被x整除的个数s2 = v/y是能被y整除数的个数,s3 = v/lcm(x, y)是能被x,y的最小公倍数整除的个数!  那么 v-s1>=c1 && v-s2>=c2 && v-s3>=c1+c2就是二分的条件! #include&

UVA10325--- The Lottery (容斥)

#include <iostream> #include <cstdio> using namespace std; typedef long long LL; LL get[18]; LL gcd(LL m, LL n) { if(n == 0) return m; return gcd(n, m%n); } LL lcm(LL a, LL b) { LL t=gcd(a, b); return a/t*b; } int main() { int n,m; while(cin&g

HDU 2048:递推&amp;amp;错排概率

神.上帝以及老天爷 http://acm.hdu.edu.cn/showproblem.php?pid=2048 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Problem Description HDU 2006'10 ACM contest的颁奖晚会隆重开始了! 为了活跃气氛,组织者举行了一个别开生面.奖品丰厚的抽奖活动,这个活动的具体要求是这样的: 首先,所有参加晚会的人员

欧拉函数性质

先来介绍几个与欧拉函数有关的定理: 定理一:设m与n是互素的正整数,那么 定理二:当n为奇数时,有. 因为2n是偶数,偶数与偶数一定不互素,所以只考虑2n与小于它的奇数互素的情况,则恰好就等于n的欧拉函数值. 定理三:设p是素数,a是一个正整数,那么 关于这个定理的证明用到容斥: 由于表示小于与互素数的正整数个数,所以用减去与它不互素的数的个数就行了. 那么小于与不互素数的个数就是p的倍数个数,有个.所以定理得证. 定理四:设为正整数n的素数幂分解,那么 这个定理可以根据定理一和定理三证明,其实

融合极速体验,苹果 Fusion Drive 技术全面解析

在前不久的新品发布会上,苹果为大家带来了新一代iMac一体机,它不仅拥有超薄的机身,同时还内置了苹果的一项新技术--Fusion Drive技术.该技术是之前的产品中并未有过的,是一项全新的技术.我们把它称作混合式硬盘分层管理技术,或者混合存储系统.顾名思义,该技术利用软件让SSD与传统硬盘做混合数据处理,达到接近标准于SSD的体验效果.今天我们就围绕Fusion Drive技术展开讨论. 首先提一下,实际上这项Fusion Drive技术在一年前就已经曝光过,但并未引起用户注意.笔者翻阅了之前

UVa 11538 Chess Queen:组合&amp;amp;分类

11538 - Chess Queen Time limit: 2.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=469&page=show_problem&problem=2533 You probably know how the game of chess is played and how chess queen operates.

UVa 11401 Triangle Counting:组合计数

11401 - Triangle Counting Time limit: 1.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=469&page=show_problem&problem=2396 You are given n rods of length 1, 2-, n. You have to pick any 3 of them &a

构建SOA组合业务服务专题

从 2007 年年初开始,我们陆续地向您推出了"构建 SOA 组合业务服务"系 列文章.它通过一个银行业的例子十分全面地向您介绍了如何构建 SOA 组合业务服务以及相 关方方面面的知识.同时还涉及了很多 IBM 相关的产品,比如Websphere Process Server, WebSphere Integration Developer,WebSphere Portlet,Rational Application Developer 和 DB2 Universal Database