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 ...
随机推荐
- Theos简介
[Theos简介] Theos is a cross-platform suite of development tools for managing, developing, and deployi ...
- IDEA MAVEN 1.8无效的源发行版
最近想将自己在IDEA上开发的MAVEN项目切换到JDK1.8版本上,结果IDEA报1.8无效的源发行版.下面说一下自己的解决方案: 1.pom文件 <build> <plugins ...
- Build Path
------------siwuxie095 什么是 Build Path? 为什么使用 Build Path? 如: (1)创建一个Java工程:LearnBuildPath (2)点击 Next, ...
- RabbitMQ(pika模块)
RabbitMQ 基础 2 3 4 5 6 7 8 安装配置epel源 $ rpm -ivh http://dl.fedoraproject.org/pub/epel/6/i386/epel-r ...
- poj1722 SUBTRACT
应该是基础的dp练手题 线性dp最主要的就是关于阶段的划分,这个题中我没想到的一点就是开状态的时候使用了前i个数能合成的数来记录 我自己的想法就是类似于区间dp这样的记录方法,这种方法确实开了很多冗余 ...
- 网页中的foot底部定位问题
有时候,我们会碰到这样一个问题. 网页底部一般有个foot对吧,放置一些友情链接版权声明什么的,这个模块是如何定位的? 要是直接放内容区域的下面的话,假如是内容区域的高度不够的话,那么foot下面是会 ...
- bootstrap实现菜单定位
<!DOCTYPE html><html lang="zh-cn"><head><meta charset="utf-8&quo ...
- 编写高质量代码改善C#程序的157个建议——建议15: 使用dynamic来简化反射实现
建议15: 使用dynamic来简化反射实现 dynamic是Framework 4.0的新特性.dynamic的出现让C#具有了弱语言类型的特性.编译器在编译的时候不再对类型进行检查,编译器默认dy ...
- Sharepoint 文档知识管理系统--Word在试图打开文件时遇到错误
在系统开发中,遇到问题:SharePoint 2010与Office 2010安装在一台服务器上,当用Office打开SharePoint文档库中的文档时,遇到“Word在试图打开文件时遇到错误,请尝 ...
- Linux 命令之chcon
chcon命令:修改对象(文件)的安全上下文.比如:用户:角色:类型:安全级别.主要用在selinux中用来更改安全上下文.命令格式: Chcon [OPTIONS…] CONTEXT FILES…. ...