lightoj--1005--Rooks(组合数)】的更多相关文章

A rook is a piece used in the game of chess which is played on a board of square grids. A rook can only move vertically or horizontally from its current position and two rooks attack each other if one is on the path of the other. In the following fig…
1005 - Rooks   PDF (English) Statistics Forum Time Limit: 1 second(s) Memory Limit: 32 MB A rook is a piece used in the game of chess which is played on a board of square grids. A rook can only move vertically or horizontally from its current positio…
https://vjudge.net/problem/LightOJ-1005 题意:在n*n的矩形上放k个车,使得它们不能互相攻击,求方案数. ans[i][j]表示在i*i的矩形上放j个车的方案数. 那么,首先要在(i-1)*(i-1)的矩形上放j-1个,再在比(i-1)*(i-1)多出来的一行一列上放.这多出来的一行一列不是指最下最右的那个,而是以任意方式插入进(i-1)*(i-1).共有i*i种插入方式.插入之后,在插入的一行一列的交点处放一个车.列几个例子可以发现,这样子产生的方法,每…
题目链接:http://www.lightoj.com/volume_showproblem.php?problem=1005 纸上画一下,找了一下规律,Ank*Cnk. //#pragma comment(linker, "/STACK:102400000, 102400000") #include <algorithm> #include <iostream> #include <cstdlib> #include <cstring>…
题目链接:http://lightoj.com/volume_showproblem.php?problem=1005 #include <cstdio> #include <cstring> #include <iostream> #include <cmath> #include <algorithm> #include <queue> #include <vector> using namespace std; ;…
版权声明:本文作者靖心.靖空间地址:http://blog.csdn.net/kenden23/,未经本作者同意不得转载. https://blog.csdn.net/kenden23/article/details/31760795 A rook is a piece used in the game of chess which is played on a board of square grids. A rook can only move vertically or horizonta…
组合数学,ans = C(n,k)*A(n,k). #include<cstdio> #include<string> #include<cstring> #include<iostream> #include<algorithm> #define LL long long using namespace std; LL work(int n, int k){ if(k > n) return 0; LL sum1 = 1L, sum2 =…
题目大意: 给你一个N和K要求确定有多少种放法,使得没有两个车在一条线上. N*N的矩阵, 有K个棋子. 题目分析: 我是用DP来写的,关于子结构的考虑是这样的. 假设第n*n的矩阵放k个棋子那么,这个推导过程如下.   当我们们第n*n的矩阵的时候可以考虑第(n-1)*(n-1)的矩阵经过哪些变换可以变成n*n的. 如上图蓝色方格.我们加入蓝色方格之后,矩阵就会增大一圈. 1.加入我们蓝色方格不放置棋子. dp[n-1][k] 2.加入蓝色方格放置一枚棋子,那么我们其实有三种位置可以放置:(1…
免费做一样新 1004 - Monkey Banana Problem 号码塔 1005 - Rooks 排列 1013 - Love Calculator LCS变形 dp[i][j][k]对于第一个字符串i 到jLCS为k的方案数 1068 - Investigation 数位dp 能被K整数且各位数字之和也能被K整除的数 dp[i][j][k] 到第i位每位数字之和的余数为j 当前数字余数为k 1079 - Just another Robbery 01背包 全部钱之和为背包体积 不被抓的…
http://www.lightoj.com/volume_showproblem.php?problem=1005        PDF (English) Statistics Forum Time Limit: 1 second(s) Memory Limit: 32 MB A rook is a piece used in the game of chess which is played on a board of square grids. A rook can only move…