uva11806 - Cheerleaders 容斥原理

uva 11806 - Cheerleaders(容斥原理) 题目链接:uva 11806 - Cheerleaders 题目大意:在一个m行n列的矩阵网里放k个石子,问有多少种画法?每个格子最多放一个石子,所有石子必须用完,并且在第一行、最后一行、第一列和最后一列都得有石子。 解题思路:容斥原理,我们可以先求说在m∗n的矩阵上放k个石子的种数C(nmk),减掉四条边界不放的情况就是答案了。所以枚举16种状态,用二进制数表示说四条边中那些边是不放 阅读详情

Inmost professional sporting events, cheerleaders play a major role inentertaining the spectators. Their roles are substantial during breaks andprior to start of play. The world cup soccer is no exception. Usually thecheerleaders form a group and perform at the centre of the field. In additionto this group, some of them are placed outside the side line so they are closerto the spectators. The organizers would like to ensure that at least onecheerleader is located on each of the four sides. For this problem, we willmodel the playing ground as an M*Nrectangular grid. The constraints for placing cheerleaders are described below:

 

§  There should be at least one cheerleader oneach of the four sides. Note that, placing a cheerleader on a corner cell wouldcover two sides simultaneously.

§  There can be at most one cheerleader in acell.

§  All the cheerleaders available must beassigned to a cell. That is, none of them can be left out.

 

 

Theorganizers would like to know, how many ways they can place the cheerleaderswhile maintaining the above constraints. Two placements are different, if thereis at least one cell which contains a cheerleader in one of the placement butnot in the other. 

 

 

 

Input

 

Thefirst line of input contains a positive integer T<=50, which denotes the number of test cases. T lines then follow each describing onetest case. Each case consists of three nonnegative integers, 2<=M, N<=20 and K<=500. Here M is the number of rows and Nis the number of columns in the grid. Kdenotes the number of cheerleaders that must be assigned to the cells in thegrid.

 

 

Output

 

For each case of input, there will be one line ofoutput. It will first contain the case number followed by the number of ways toplace the cheerleaders as described earlier. Look at the sample output forexact formatting. Note that, the numbers can be arbitrarily large. Thereforeyou must output the answers modulo 1000007.

 

Sample Input

Sample Output

2

2 2 1

2 3 2

Case 1: 0

Case 2: 2

 

  M*N的矩形网格里放K个相同石子,第一行,第一列,最后一行,最后一列一定要有石子,问有多少种方法。

  设第一行没有石子的方案集为A,最后一行没有石子的方案集为B,第一列没有石子的方案集为C,最后一列没有石子的方案集为D,全集为S(S对应空搭配),答案就是在S中但不在ABCD任何一个集合中的元素个数。

  这就是容斥原理了,奇偶加减不一样。注意(a-b)%M=(a%M-b%M+M)%M。

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<cstdlib>
#include<cmath>
#define INF 0x3f3f3f3f
#define MAXN 510
#define MAXM 20010
#define MAXNODE 4*MAXN
#define MOD 1000007
#define eps 1e-9
using namespace std;
int T,M,N,K;
long long C[MAXN][MAXN];
void init(){
    for(int i=0;i<MAXN;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(){
    freopen("in.txt","r",stdin);
    init();
    int cas=0;
    scanf("%d",&T);
    while(T--){
        scanf("%d%d%d",&M,&N,&K);
        int S=M*N;
        long long sum=0;
        for(int S=0;S<16;S++){
            int cnt=0,r=M,c=N;
            if(S&1){
                r--;
                cnt++;
            }
            if(S&2){
                r--;
                cnt++;
            }
            if(S&4){
                c--;
                cnt++;
            }
            if(S&8){
                c--;
                cnt++;
            }
            if(cnt&1) sum=(sum+MOD-C[r*c][K])%MOD;
            else sum=(sum+C[r*c][K])%MOD;
        }
        printf("Case %d: %d\n",++cas,sum);
    }
    return 0;
}



UVA 11806 Cheerleaders(容斥原理) 总方案数减去不站人的方案数,分别是第一行不站人,最后一行不站人,第一列不站人,最后一列不站人。因为区间有重叠,所以要用容斥原理来做就好。给一个n*m的地图和k个人,要求地图的第一列、行,最后一列、行都要有人,求有多少种方法。这道题的数据很小,模数不是质数,而且很大,所以最好用递推预处理求组合数。... 阅读详情

相关推荐

脑电数据预处理八:基于 ICA 的伪迹去除

摘要: 脑电图(EEG)数据分析中,伪迹(如眼电、心电、肌电)与脑电信号频谱重叠时,独立成分分析(ICA)成为有效工具。ICA通过盲源分离将混合信号分解为统计独立的成分,识别并移除伪迹后重建干净信号。MNE-Python实现步骤包括:数据预处理(滤波、坏导处理)、ICA分解、人工与自动结合识别伪迹成分、剔除后重建数据。实践建议强调人工检查的重要性,避免过度使用ICA,并保存模型以提高效率。该方法显著提升数据质量,为后续分析奠定基础。

qq_32516809的博客 1658

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 ex...

苏格拉没有底 430

用WorkBuddy和ima搭建本地知识库:从概念到实操

在AI应用普及的今天,私有知识的高效管理与调用成为痛点。RAG(检索增强生成)技术通过将外部知识库与语言模型耦合,为精准问答提供了技术底座。然而,传统RAG方案往往涉及向量数据库、文本切分等复杂环节。一种更轻量的路径应运而生:借助WorkBuddy与ima的组合,将知识收集、语义检索与智能体工作流整合,让本地知识库真正服务于日常办公和研发场景。从概念到实操,系统解析这套轻量级方案的核心逻辑与配置方法,并对比重方案适用边界,帮助读者快速搭建属于自己的AI知识助手。

weixin_32830601的博客 419

UVA 11806 Cheerleaders (容斥原理

1.题意描述 本题大致意思是讲:给定一个广场,把它分为M行N列的正方形小框。现在给定有K个拉拉队员,每一个拉拉队员需要站在小框内进行表演。但是表演过程中有如下要求: (1)每一个小框只能站立一个拉拉队员; (2)广场的第一行,最后一行,第一列,最后一列都至少站有一个拉拉队员; (3)站在广场的四个角落的拉拉队员可以认为是同时占据了一行和一列。 2.思路分析: 本题如果直接...

YZ930035683的博客 250

SAR成像处理基本知识2——图像尺寸与回波尺寸的关系

阅读本文前,请先了解上一篇文章(SAR成像处理基本知识1——常用专用名词解释) 1. SAR图像尺寸预估方法 以C波段2m@20km的SAR图像为例,假设天线中心下视角为35° ,说明图像尺寸的估计方法。 1.1 距离向尺寸估计 地距分辨率为2m时,距离向分辨率约为1.15m,则要求信号带宽不小于130MHz,假设信号带宽为150MHz,采样率为180MHz,那么距离向分辨单元为0.833m。 地距幅宽为20km时,距离向幅宽约为20*sind(3...

爱学习的小伟的博客 4954

Python爬虫实战【房产刚需专属】:爬取链家/贝壳完整房源数据,精准筛选刚需房源【房价+户型+地段+面积+装修】

本次爬虫的核心亮点就是刚需专属筛选,我已经把刚需买房的主流筛选逻辑封装为独立函数,你只需要修改筛选参数,就能精准匹配你的需求无需懂Python语法,直接改数字/文字即可!本次爬虫是刚需买房+Python爬虫实战的完美结合。

专注于Python爬虫开发,分享爬虫技巧、项目实战与反爬经验,使用Scrapy、BeautifulSoup等工具,解决数据抓取难题。 1824

【Uva11806】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

清疚的博客 489

​ISP算法及架构分析介绍

ISP算法及架构分析介绍ISP即Image Signal Processor,是一种图像处理架构,不是我们用的下载器。ISP其实算是图像处理的一个特例,一般应用于前端设备(相对于SENSOR),从结果上看就是将RAW数据转换成压缩后的RGB(一般)数据,供后续CPU使用(识别、压缩等)。市面上很少有直接介绍ISP的书籍或者资料,今天我们主要是聊一聊ISP算法的架构,这样大...

OpenFPGA的博客 5404

【ICPC-25】uva 11806 - Cheerleaders

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

藏经阁 | 玄苦 1858

YOLOv11 模型改进:利用新型损失函数实现精度跃升(含代码全解析)

在目标检测领域,损失函数的选择直接决定模型的精度上限。某自动驾驶公司将 YOLOv11 原有损失替换为新型损失后,障碍物检测 mAP 提升 10%,夜间场景误检率降低 22%;某物流分拣项目中,采用新损失的 YOLOv11 模型对小包裹的识别准确率从 82% 升至 96%。如果你也在为模型精度瓶颈、样本不平衡问题困扰,这篇教程将带你掌握 YOLOv11 损失函数的进阶技巧,真正帮你在检测性能上实现突破。损失函数是模型训练的“指南针”,它定义了模型“学习的方向”。传统损失(如 BCE、Focal Loss)在

m0_71589036的博客 713

人工智能_大模型095_Web版003_deepseek R1本地安装_私有化部署_支持RAG_调用HTTPAPI做自己的AI应用_安装RagFlow以及使用_---人工智能工作笔记0240

这里的一定要注意,是资源不够用了,可以点击ragflow-server左边的小绿点,查看 结果。注意去把内存改成10G把至少,我这里改成了10G,因为电脑一共就16G,再试试吧.可以看日志,就显示的是没有连接上mysql,结果我一看,mysql,根本没启动.然后下面选择general就可以了,然后点击确定,然后再去点击。手动去启动,然后再去试试,注意,内存这里给8G太小了还是.调成8G了,然后硬盘大了大了一些换成50G了,然后。点击系统模型设置可以看到,选择聊天模型就可以了,

添柴程序猿的专栏 447

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

UVA.11806 Cheerleaders (组合数学 容斥原理 二进制枚举)题意分析给出n*m的矩形格子,给出k个点,每个格子里面可以放一个点。现在要求格子的最外围一圈的每行每列,至少要放一个点,并且放在角上的点,同时算那个角所在的行和所在的列。不允许剩下点,求总共的方案数量,结果对1000007取模。 数据范围2 ≤ M,N ≤ 20,K ≤ 500。考虑到要求组合数目,首先就需要预处理50

Pengwill's Blog 654

Far planner代码系列(2)

graph_decoder系列(2) 承接上文 我们接着来看decoder_node.cpp的代码部分 void GraphDecoder::Init() { /* initialize subscriber and publisher */ //graph_sub_ 订阅节点/robot_vgraph 其类型是visibility_graph_msg/Graph的消息 graph_sub_ = nh.subscribe("/robot_vgrap...

博客 1534

容斥原理——Uva11806-Cheerleaders

vjudge链接:Uva11806-Cheerleaders 题目大意:给一个 n∗mn*m 的矩形网格放置 kk 个相同的石子;有多少种组合。每个方格最多放一个石子,所有石头都要放置完,并且第一行,最后一行,第一列,最后一列都一定要有石子。 求这种情况讨论的话十分麻烦,但是可以考虑间接的求取,比如:求第一行,最后一行,第一列,最后一列都没有石子的情况就很简单,就是组合数 C((m−2)×(n−

kuangle的博客 317

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

UVA11806 Cheerleaders 容斥原理

给出一个n,m≤20n,m\leq20n,m≤20的棋盘,然后要在棋盘上放kkk个棋子,但是第111行,第nnn行和第111列,第mmm列都必须要有棋子。

qq_40859782的博客 170

android 蓝牙通讯demo

android 下蓝牙通讯demo,实现了发现蓝牙,使能蓝牙,通过蓝牙发送消息。

Cheerleaders UVA - 11806 (组合数学+容斥原理)

题目链接:https://cn.vjudge.net/problem/UVA-11806 题意:有一个n行m列的矩形网格里放k个相同的石子,问有多少种方法,每个格子最多放一个石子,所有石子都要用完,并且第一行,最后一行,第一列,最后一列,都得有石子。 题解:容斥,用二进制表示所有的状态, 每一位分别代表第一行,最后一行,第一列,最后一列的状态, 0代表放,1代表不放,有0000到1111个...

- 295

STM32F407中文手册

STM32f407中文手册 本参考手册面向应用开发人员,提供有关使用 STM32F405xx/07xx、STM32F415xx/17xx、 STM32F42xxx 和 STM32F43xxx 微控制器存储器与外设的完整信息。STM32F405xx/07xx、STM32F415xx/17xx、STM32F42xxx 和 STM32F43xxx 构成一个微 控制器系列,各产品具有不同的存储器大小、封装和外设。有关订购信息以及器件的机械与电气特性,请参见数据手册。有关 ARM Cortex™-M4F 内核的信息,请参见《Cortex™-M4F 技术参考手册》。

UVA 11806 Cheerleaders (容斥原理+二进制枚举)

UVA 11806 Cheerleaders (容斥原理+二进制枚举) :http://acm.hust.edu.cn/vjudge/contest/view.action?cid=110771#problem/G  传送门:nefu 题目大意: 往一个n*m的格子内部放k个石子,要求四个边上必须都有,求所有放置石子的方法数。 题目分析: 由于正常去做需要考虑的情况种类数比较多,所以我们反

而濡木染 711

UVA - 11806(Cheerleaders)容斥原理

题意: 给定n、m、k三个数,n代表行数,m代表列数,k代表人数。 n*m的表格,一共有k个人,要求: 每个小格只能容纳一个人,所有人必须都在表格中。 第一行、第一列、最后一行、最后一列必须站人。 若夹角处站人,则代表此行和列都已站人。 题解: 利用容斥原理,设: S为总数。(n*m中选k个位置,即) A为第一行没有站人。(少一行) B为最后一行没有站人。(少一行) C...

Vici__ 470

UVA 11806 Cheerleaders (容斥原理)

题目:http://uva.onlinejudge.org/external/118/11806.pdf 题意:给定n*m的棋盘和k个一样的石头,最上面和最下面一行,最左边和最右边一列必须放石头,问有多少中方案数。 分析:容斥原理。设最上面一行不放石头的方案为集合A,最下面一行不放的方案为集合B,最左边不放的方案为集合C,最右边放的方案为集合D,全集为S。那么答案就是|S|-|A∪B∪C∪D|

w20810的专栏 636

UVa11806 Cheerleaders(容斥原理)

题意: 给出一个n*m的棋盘,在上面放k个棋子,求第一行,第一列,最后一行,最后一列每个都有棋子的组合数。 要点: 简单的容斥原理,对第一行,第一列,最后一行,最后一列没有棋子进行容斥,这样最后减去即可。注意进行容斥时如果是相减的可能出现负数,所以在前面+MOD。 #include #include #include #define MOD 1000007 using namespace

SeasonJoe的博客 470

uva 11806 Cheerleaders (容斥原理)

计算一个n*m的格子放k个球的方案数,要求第一行,第一列,最后一行,最后一列,都要有球。 直接计算显然是由点复杂,根据容斥原理,先求逆问题,也就是:第一行有球||第一列有球||最后一行有球||最后一列有球。这些都比较好求,然后用总数减去就是答案。 #include #include #include #include #include #include #include #include #i

ACM之梦 614

uva 11806 Cheerleaders【容斥原理】

初次接触容斥原理 设 A 为第一行没人      B为最后一行没人 C为第一列没人 D为最后一列没人 那么我们想要的结果      jg=全集-A-B-C-D+AB+AC+AD+BC+BD+CD-BCD-ACD-ABD-ABC+ABCD 代码中使用1~15的二进制把上述集合表示了。 In most professional sporting events, cheer

nuanxin_520的专栏 379

UVA 11806 Cheerleaders(容斥原理)

题目地址:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2906 思路:A表示第一行无石子,B表示最后一行无石子,C表示第一列无石子,D表示最后一列无石子。A=B=c[(n-1)*m][k],C=D=c[n*(m-1)][k]。tot=c[n*m][k

哆啦AC梦的博客 890

UVa 11806 Cheerleaders / 容斥原理

求k个石子放在n*m的矩阵里 并且第一行 最后一行 第一列 最后一列都要有石子 考虑反面 求出所有的 减去不满足的情况 容斥原理总共4个 集合A(第一行没有石子) B(最后行没有石子)C(第一列没有石子)D(最后一列没有石子) 减去1个集合的 加上2个集合的 减去3个集合的 加上4个集合的 #include #include const int maxn = 510; const i

嗯。 1411
上一篇: hdu3980 Paint Chain SG函数
下一篇: uva11361 - Investigating Div-Sum Property 数位统计DP
小小小小葱
博客等级 码龄14年 22粉丝 266原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值