Cheerleaders UVA - 11806 计数问题
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<bitset>
#include<ctime>
#include<deque>
#include<stack>
#include<functional>
#include<sstream>
//#include<cctype>
//#pragma GCC optimize(2)
using namespace std;
#define maxn 2000005
#define inf 0x7fffffff
//#define INF 1e18
#define rdint(x) scanf("%d",&x)
#define rdllt(x) scanf("%lld",&x)
#define rdult(x) scanf("%lu",&x)
#define rdlf(x) scanf("%lf",&x)
#define rdstr(x) scanf("%s",x)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int U;
#define ms(x) memset((x),0,sizeof(x))
const long long int mod = 1e6 + 7;
#define Mod 1000000000
#define sq(x) (x)*(x)
#define eps 1e-4
typedef pair<int, int> pii;
#define pi acos(-1.0)
//const int N = 1005;
#define REP(i,n) for(int i=0;i<(n);i++)
typedef pair<int, int> pii;
inline ll rd() {
ll x = 0;
char c = getchar();
bool f = false;
while (!isdigit(c)) {
if (c == '-') f = true;
c = getchar();
}
while (isdigit(c)) {
x = (x << 1) + (x << 3) + (c ^ 48);
c = getchar();
}
return f ? -x : x;
} ll gcd(ll a, ll b) {
return b == 0 ? a : gcd(b, a%b);
}
int sqr(int x) { return x * x; } /*ll ans;
ll exgcd(ll a, ll b, ll &x, ll &y) {
if (!b) {
x = 1; y = 0; return a;
}
ans = exgcd(b, a%b, x, y);
ll t = x; x = y; y = t - a / b * y;
return ans;
}
*/ int c[503][503];
int n, m, k;
void init() {
c[0][0] = 1;
for (int i = 0; i <= 503; i++) {
c[i][0] = c[i][i] = 1;
for (int j = 1; j < i; j++)c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % mod;
}
} int main() {
// ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int T; cin >> T;
init(); int tot = 0;
while (T--) {
tot++;
cin >> n >> m >> k;
cout << "Case " << tot << ": ";
int sum = 0;
for (int i = 0; i < 16; i++) {
int bk = 0;
int r = n, C = m;
if (i & 1) { bk++; r--; }
if (i & 2) { bk++; r--; }
if (i & 4) { bk++; C--; }
if (i & 8) { bk++; C--; }
if (bk % 2) {
sum = (sum + mod - c[C*r][k]) % mod;
}
else sum = (sum + c[C*r][k]) % mod;
}
cout << sum << endl;
}
return 0;
}
Cheerleaders UVA - 11806 计数问题的更多相关文章
- Cheerleaders UVA - 11806
题目大意是: 在一个m行n列的矩形网格中放置k个相同的石子,问有多少种方法?每个格子最多放一个石子,所有石子都要用完,并且第一行.最后一行.第一列.最后一列都要有石子. 容斥原理.如果只是n * m放 ...
- Cheerleaders UVA - 11806(容斥+二进制技巧)
#include <iostream> #include <cstdio> #include <sstream> #include <cstring> ...
- uva 11806 Cheerleaders
// uva 11806 Cheerleaders // // 题目大意: // // 给你n * m的矩形格子,要求放k个相同的石子,使得矩形的第一行 // 第一列,最后一行,最后一列都必须有石子. ...
- UVA.11806 Cheerleaders (组合数学 容斥原理 二进制枚举)
UVA.11806 Cheerleaders (组合数学 容斥原理 二进制枚举) 题意分析 给出n*m的矩形格子,给出k个点,每个格子里面可以放一个点.现在要求格子的最外围一圈的每行每列,至少要放一个 ...
- UVA 11806 Cheerleaders dp+容斥
In most professional sporting events, cheerleaders play a major role in entertaining the spectators. ...
- UVa 11806 Cheerleaders (容斥原理+二进制表示状态)
In most professional sporting events, cheerleaders play a major role in entertaining the spectators. ...
- uva 11806 Cheerleaders (容斥)
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&p ...
- UVA 11806 Cheerleaders (组合+容斥原理)
自己写的代码: #include <iostream> #include <stdio.h> #include <string.h> /* 题意:相当于在一个m*n ...
- UVA 11806 Cheerleaders (容斥原理)
题意 一个n*m的区域内,放k个啦啦队员,第一行,最后一行,第一列,最后一列一定要放,一共有多少种方法. 思路 设A1表示第一行放,A2表示最后一行放,A3表示第一列放,A4表示最后一列放,则要求|A ...
随机推荐
- Minimum Sum of Array(map)
You are given an array a consisting of n integers a1, ..., an. In one operation, you can choose 2 el ...
- sonarLint 插件配置sonarQube Server
Connected Mode You can bind Eclipse projects to a SonarQube project (supporting SonarQube servers 5. ...
- FPGA和CPLD的比较
1 FPGA的集成度比CPLD高,具有更复杂的布线结构和逻辑实现. 2 CPLD更适合触发器有限而乘积丰富的结构,更适合完成复杂的组合逻辑:FPGA更适合于触发器丰富的结构,适合完成时序逻辑. 3 c ...
- spring注解创建对象
- SPQuery DateTime 类型查询
使用SPQuery查询时间,默认查询会忽略 时分秒,只检查日期,如果要检查时间,则必须添加 IncludeTimeValue='TRUE' 格式如下: <Where> <Gt& ...
- c++ 适配器模式(adapter)
当两个系统的接口不一样时,我们就要重新封装一下接口,以便于当前系统的调用.这种模式叫做适配器模式.适配器模式分为两种: 1.对象组合适配器(Object Adapter) 2.类适配器(Class A ...
- 12-在eclipse上安装lxml
1.可用easy_install安装方式,也可以用pip的方式: pip install lxml 2.安装完毕:写代码导包时提示错误,这是需要配置一下eclipse,是因为它没有更新导入的包,所以需 ...
- Vue 与Angular、React框架的对比
首先,我们先了解什么是MVX框架模式? MVX框架模式:MVC+MVP+MVVM 1.MVC:Model(模型)+View(视图)+controller(控制器),主要是基于分层的目的,让彼此的职责分 ...
- 第七课 ROS的空间描述和变换
在命令行工具中也有一个与transformcaster相类似的工具叫做static_transform_publisher,它能够接受命令行参数来接受位置信息.旋转信息.父框架.子框架以及周期信息,通 ...
- URAL 1204. Idempotents (扩展欧几里得)
题目链接 题意 : 给你一个同余方程, x*x ≡ x (mod n),让你求出所有的小于n的x. 思路 : 先来看同余的概念 :给定一个正整数m,如果两个整数a和b满足a-b能被m整除,即m|(a ...