状态:d[i]代表n=i时的方案数. 状态转移方程:d[i]=d[i-2]+2*(d[i-2]+d[i-4]+-+d[0]) i只会为偶数,奇数情况不存在,d[0]=1 找状态转移方程的时候画图更好理解. #include <iostream> #include <cstdio> #include <algorithm> using namespace std; int d[50]; int main() { int n; d[0]=1; d[2]=3; int sum…
Tri Tiling Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 10306 Accepted: 5237 Description In how many ways can you tile a 3xn rectangle with 2x1 domino…
Tri Tiling Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 7841 Accepted: 4113 Description In how many ways can you tile a 3xn rectangle with 2x1 dominoes? Here is a sample tiling of a 3x12 rectangle. Input Input consists of several t…
Description In how many ways can you tile a 3xn rectangle with 2x1 dominoes? Here is a sample tiling of a 3x12 rectangle. Input Input consists of several test cases followed by a line containing -1. Each test case is a line containing an integer 0 <…
本来直接一波状压dpAC的 #include<cstdio> #include<cstring> #include<algorithm> #define REP(i, a, b) for(int i = (a); i < (b); i++) #define _for(i, a, b) for(int i = (a); i <= (b); i++) using namespace std; typedef long long ll; ll dp[50][10]…
E. Mahmoud and Ehab and the xor-MST dp/数学/找规律 题意 给出一个完全图的阶数n(1e18),点由0---n-1编号,边的权则为编号间的异或,问最小生成树是多少 思路 由于一个数k和比他小的数异或,一定可以取到k与所有正整数形成的异或值的最小值.这里简单得形式化证明一下 假设一个数为1000110 那么他的最佳异或和为010(即留下最靠近右边的1其他全部置0) 我们定义\(lsb(x)=x\And(-x)\)由字符形的变量编码我们可以知道,这就可以取得x最…