Rooks LightOJ - 1005】的更多相关文章

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种插入方式.插入之后,在插入的一行一列的交点处放一个车.列几个例子可以发现,这样子产生的方法,每…
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…
题目链接: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; ;…
组合数学,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 =…
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…
题目链接: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>…
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…
版权声明:本文作者靖心.靖空间地址: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…
题目大意: 给你一个N和K要求确定有多少种放法,使得没有两个车在一条线上. N*N的矩阵, 有K个棋子. 题目分析: 我是用DP来写的,关于子结构的考虑是这样的. 假设第n*n的矩阵放k个棋子那么,这个推导过程如下.   当我们们第n*n的矩阵的时候可以考虑第(n-1)*(n-1)的矩阵经过哪些变换可以变成n*n的. 如上图蓝色方格.我们加入蓝色方格之后,矩阵就会增大一圈. 1.加入我们蓝色方格不放置棋子. dp[n-1][k] 2.加入蓝色方格放置一枚棋子,那么我们其实有三种位置可以放置:(1…
题目链接:http://lightoj.com/volume_showproblem.php?problem=1172 题意:一个n进制(2<=n<=6)的数字,满足以下条件:(1)至少包含两位且不以0开头,比如012是不行的:(2)相邻数字不同:(3)定义这个数字x的score(x)等于相邻数字差的平方和,比如score(125)=(1-2)*(1-2)+(2-5)*(2-5)=10.现在给出n和m,求满足条件的所有n进制的数字中有多少数字的score为m.(1<=m<=10^9…