摘要:#define FOR(i,s,t) for(int i=(s);i>= 1; b1 = i&1; i >>= 1; b2 = i&1; } int sign(int b0, int b1, int b2) { return (b0 + b1 + b2) % 2 == 1 ? 1 : -1; } { FOR(x,1,a) FOR(y,1,b) FOR...
阅读全文
摘要:核心是要想到只枚举最小公倍数的因子 因为转移过程中一单添加了不是最小公倍数的因子,那么结果必然不合法,虽然最终答案是对的,但是这样的答案根本用不上,反而时间复杂度大大增加
阅读全文
摘要:https://blog.csdn.net/flyinghearts/article/details/5898183 完美的讲解 POJ2392
阅读全文
摘要:很显然是单调栈 这里记录一种新的写法,这种写法基于递推,但是相比之下比单调栈更好写
阅读全文
摘要:虽然只是B题,还是div2的 但感觉挺有意思,所以写一篇博客记录一下 最初的想法是利用DP去做,f[s]=true表示字符串s对应先手赢,否则对应后手赢,大致想了下发现是指数级别的算法,看了下范围直接pass掉 然后就接着想,发现如果两个相等的字符被消掉之后,相等字符的周边靠过来,如果还能消除的话他
阅读全文
摘要:和紫书上的Blocks UVA - 10559 几乎是同一道题,只不过是得分计算不同 不过看了半天紫书上的题才会的,当时理解不够深刻啊 不过这是一道很好区间DP题 细节看代码
阅读全文
摘要:#include using namespace std; typedef long long ll; struct node{ int x,y; ll setp; }; queue Q,border[10]; const int maxn=1005; char a[maxn][maxn]; int vis[maxn][maxn]; int n,m,p; ll ans[10],s...
阅读全文
摘要:#include #include #include using namespace std; const int maxn=55; int n; bool g[maxn][maxn]; bool found; int len[maxn],list[maxn][maxn],ans,mc[maxn]; void dfs(int size) { if(len[size]==0...
阅读全文