题意:给定当前汉诺塔的状态,问还有多少步走完,不合法输出“No”. 思路:显然可以一层一层试探下去的.我们设三个柱子为“起始”,“中转”,“终点”,当前状态的最大的盘子不可能在中转站处:如果在起始站,我们需要把其他的移到中转站,然后把最大移到终点.如果在终点站,我们需要把其他的从中转站移到终点站. 每一层减少一个盘子,递推下去就ok了.当时想到了思路,但是没有想到简洁的写法. #include<bits/stdc++.h> #define ll long long using namespac…
题意:给n个元素,从n中选两个非空集合A和B.问有多少中选法? 递推: dp[n]表示元素个数为n的方案数,对于新来的一个元素,要么加入集合,要么不加入集合自成一个集合.加入集合有三种选择,A,B,E(可空的集合),或者自成集合,作为A或B,然后在选一个n-1个元素的非空子集(2^n-1 - 1). #include<cstdio> ; typedef unsigned long long ll; int main() { int n; scanf("%d",&n)…
题目:假如有A,B两个人,在一个m*n的矩阵,然后A在(1,1),B在(m,1),A要走到(m,n),B要走到(1,n),两人走的过程中可以捡起格子上的数字,而且两人速度不一样,可以同时到一个点(哪怕这个点离A很近,离B很远),现在A,B起码相遇于一个点点,相遇点的数字A,B都得不到,求最后A,B总数字之和的最大值 B. Working out Summer is coming! It's time for Iahub and Iahubina to work out, as they both…
Summer is coming! It's time for Iahub and Iahubina to work out, as they both want to look hot at the beach. The gym where they go is a matrix a with n lines and mcolumns. Let number a[i][j] represents the calories burned by performing workout at the…