题解: 列举每一种3的倍数的组合,开始先求出3条边的可行解,则 六条边的可行解可以由两个三条边得来. 详见代码解析 #include<bits/stdc++.h> using namespace std; ],n,cnt,ant,],dp[]; struct node { int num,id; }angle[]; bool cmp(const node& a,const node& b) { return a.num<b.num; } int abs1(int x) {…
Problem K. Kitchen Robot Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100610 Description Robots are becoming more and more popular. They are used nowadays not only in manufacturing plants, but also at home. One programmer wit…
ZOJ - 3777 就是一个入门状压dp期望 dp[i][j] 当前状态为i,分数为j时的情况数然后看代码 有注释 #include <iostream> #include <cstdio> #include <sstream> #include <cstring> #include <map> #include <cctype> #include <set> #include <vector> #inclu…
找循环节,肯定在40项以内,不会证明. #include <iostream> #include <cstring> #include <string> #include <map> using namespace std; ]; map<long long,bool>m; int main() { long long t; cin>>t; ;o<=t;o++) { m.clear(); long long n;//n的范围很大…
http://www.lydsy.com:808/JudgeOnline/problem.php?id=1087 状压dp是第一次写啊,我也是才学TAT.状压dp一般都用一个值表示集合作为dp的一个状态,然后根据集合和dp的性质转移.通常用于啥啥啥..... 我引用些吧 我们知道,用DP解决一个问题的时候很重要的一环就是状态的表示,一般来说,一个数组即可保存状态.但是有这样的一些题目,它们具有DP问题的特性,但是 状态中所包含的信息过多,如果要用数组来保存状态的话需要四维以上的数组.于是,我们就…
题目链接:http://www.lightoj.com/volume_showproblem.php?problem=1119 题解:状压dp存一下车有没有被搞过的状态就行. #include <iostream> #include <cstring> #include <cstdio> using namespace std; typedef long long ll; ll dp[1 << 15] , val[15][15]; int main() {…
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3777 Time Limit: 2 Seconds      Memory Limit: 65536 KB The 11th Zhejiang Provincial Collegiate Programming Contest is coming! As a problem setter, Edward is going to arrange the order…
题目链接:http://poj.org/problem?id=3311 题意:一个人到一些地方送披萨,要求找到一条路径能够遍历每一个城市后返回出发点,并且路径距离最短.最后输出最短距离即可.注意:每一个地方可重复访问多次. 经典的状压dp,因为每次送外卖不超过10个地方,可以压缩. 由于题中明确说了两个城市间的直接可达路径(即不经过其它城市结点)不一定是最短路径,所以需要借助floyd首先求出任意两个城市间的最短距离. 然后,在此基础上来求出遍历各个城市后回到出发点的最短路径的距离,即求解TSP…
多校7 HDU5816 Hearthstone 状压DP+全排列 题意:boss的PH为p,n张A牌,m张B牌.抽取一张牌,能胜利的概率是多少? 如果抽到的是A牌,当剩余牌的数目不少于2张,再从剩余牌里抽两张,否则全部拿完. 每次拿到一张B牌,对boss伤害B[i]的值 思路:dp[i]表示状态为i时的方案数 先处理出所有状态下的方案,再枚举每种状态,如果符合ans+=dp[i]*剩余数的全排列 当前集合里有a张A,b张B,那么还能取的牌数:a*-a-b+ #include <bits/stdc…
宣传墙 时间限制:1000 ms  |  内存限制:65535 KB 难度:4 描述 ALPHA 小镇风景美丽,道路整齐,干净,到此旅游的游客特别多.CBA 镇长准备在一条道路南 面 4*N 的墙上做一系列的宣传.为了统一规划,CBA 镇长要求每个宣传栏只能占相邻的两个方格 位置.但这条道路被另一条道路分割成左右两段.CBA 镇长想知道,若每个位置都贴上宣传栏, 左右两段各有有多少种不同的张贴方案. 例如: N=6,M=3, K=2, 左,右边各有 5 种不同的张贴方案 输入 第一行: T 表示…