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 ...
随机推荐
- java将类和函数封装成jar
本来想用idea安装的,不过用maven生成后发现jar有20,30M肯定不对,后来还是用eclipse生成了,方便很多 环境: eclipse luna,jdk1.8_112 1.生成jar包,首先 ...
- Spark的几个问题
1.application是由driver和executor组成的,executor可以分成task,task又可以分成为stage.当一个任务提交给spark之后,spark机群的主节点会出现dri ...
- Python 安装selenium
一.报错信息 No module named 'selenium' 二.系统环境 操作系统:Win10 64位 Python版本:Python 3.7.0 三.安装参考 1.使用pip安装seleni ...
- centos 安装mongodb3.0
一.添加yum源 vi /etc/yum.repos.d/mongodb-org-3.0.repo 请添加如下配置(64位系统): [mongodb-org-3.0] name=MongoDB Rep ...
- 28. LAST() 函数
LAST() 函数 LAST() 函数返回指定的字段中最后一个记录的值. 提示:可使用 ORDER BY 语句对记录进行排序. SQL LAST() 语法 SELECT LAST(column_nam ...
- Smarty3——内置函数
Table of Content {$var} {$append} {assign} {block} {call} {config_load} {debug} {extends} {for} {for ...
- python字符串大小写转换
str = "www.w3cSChool.cn"print(str.upper()) # 把所有字符中的小写字母转换成大写字母print(str.lower()) # 把所有字符中 ...
- 单元测试NUnit 的文章
请参考 https://www.cnblogs.com/ranh941/p/7629279.htmlhttps://blog.csdn.net/qincode/article/details/1831 ...
- Which Uri Encoding method should i use in C#/.net?
June 19, 2015 This too is one of the boring "factual" posts. Sorry Lachlan. I never know w ...
- C# JackLib系列之字体使用
字体的使用一般我们都是使用系统字体,这样比较方便,直接 Font font=new Font("微软雅黑",16f,FontStyle.Bold); 但是当我们用到一个系统没有的字 ...