摘要: 这道题是把题目给你的好像是递归的方式改变成 递推的方式, 只要预处理一下,答案就直接全部出来了#include #include #include using namespace std; int dp[22][22][22]; //w(a-1, b, c) + w(a-1, b-1, c) + w(a-1, b, c-1) - w(a-1, b-1, c-1) int main() { int a, b, c, i, j, k; for(i=0;i20||b>20||c>20) a=b=c=20; printf("w(%d, %d, %... 阅读全文
posted @ 2013-08-15 20:33 Ink_syk 阅读(98) 评论(0) 推荐(0) 编辑
摘要: 这道题目如果直接用4个for循环暴力求解显然是不行的 ,所以我用一个优化减少一个循环,又由于值是正负的,所以又可以从-100,100 变成只要循环1-100就足够#include #include #include #include #include using namespace std; bool vis[10005]; void init() { int i; memset(vis,0,sizeof(vis)); for(i=1;i0&&b>0&&c>0&&d>0)||(a0&&vis[xx]) ans+= 阅读全文
posted @ 2013-08-15 20:28 Ink_syk 阅读(145) 评论(0) 推荐(0) 编辑
摘要: #include #include #include #include using namespace std; int n, a[30005], c[30005], d[30005], k, vis[30005]; long long b[30005]; int find(int x) { int l=1, r=k-1; while(l>1; if(c[m]==x) return m; if(c[m]0) { ret+=b[p]; p-=lowbit(p); } return ret; }... 阅读全文
posted @ 2013-08-12 13:14 Ink_syk 阅读(124) 评论(0) 推荐(0) 编辑
摘要: #include #include #include #include #include #include using namespace std; char y[15], x[15]; struct Node { int va, l, r; } nod[2][15]; int r[2]; void build(int t,int k,int p) { if(t<nod[k][p].va) { if(nod[k][p].l==-1) { nod[k][r[k]].va=t; nod[k][r... 阅读全文
posted @ 2013-08-08 14:20 Ink_syk 阅读(113) 评论(0) 推荐(0) 编辑
摘要: #include #include #include #include #include #include using namespace std; bool f[1200]; int c[1100]; int main() { int i, j, m, n; while(scanf("%d",&n)!=EOF) { if(n==0) break; memset(f,0,sizeof(f)); for(i=0; i=55) f[j]=true; } } for(i=0... 阅读全文
posted @ 2013-08-05 18:53 Ink_syk 阅读(123) 评论(0) 推荐(0) 编辑
摘要: #include #include #include #include #include #include using namespace std; int n, m; char map[105][105]; bool vis[105][105][2][2][2][2]; struct node { node(int p,int q,bool a1,bool a2,bool a3,bool a4,int a5) { x=p, y=q, b=a1, ye=a2, r=a3, g=a4, now=a5; } node() {} int x, ... 阅读全文
posted @ 2013-08-04 12:09 Ink_syk 阅读(104) 评论(0) 推荐(0) 编辑
摘要: #include #include #include #include #include using namespace std; char map[22][22]; int sx, sy, ex, ey, n, m; int dx[]= {1,0,-1,0}, dy[]= {0,1,0,-1}; bool vis[22][22][22][22]; struct sta { sta(int a,int b,int c,int d,int e) { x1=a,y1=b,x2=c,y2=d,now=e; } sta() {}; int x1,... 阅读全文
posted @ 2013-08-03 21:25 Ink_syk 阅读(116) 评论(0) 推荐(0) 编辑
摘要: 代码如下:#include #include using namespace std; const int MAXN=100005; struct DATA { int l, r; __int64 d; DATA() {}; DATA(int a,int b,__int64 c):l(a),r(b),d(c) {} } op[MAXN]; __int64 a[MAXN], chg[MAXN], nop[MAXN]; int main() { int i, j, n, m, k, x, y, l, r; __int64 d; scanf("... 阅读全文
posted @ 2013-05-29 20:25 Ink_syk 阅读(137) 评论(0) 推荐(0) 编辑
摘要: 这题是将对应栈操作尽量少的步数以达到目标栈,输出操作对应的字符串。操作效果为,可选择将栈中某个字符串移动到达栈的顶层。为使操作步数最少,只需要找出我们必须移动的最大的 原始串在目标串中的位置号。那么去找那些必须移动的串,显然必须移动的串是相对位置错误的串。比如某个串上方有某个串在目标串中的位置是在他下方,那么此串必定是要移动的。#include #include #include #include #include #include #include using namespace std; const int MAXM=105, MAXN=1005; char a1[MAXN][MAXM], 阅读全文
posted @ 2013-05-04 19:27 Ink_syk 阅读(133) 评论(0) 推荐(0) 编辑
摘要: 这题就是一个特殊的队列, 我用了vector来模拟。题意是 有几个队伍,每个队伍中有编号为0—999999的队员。他们根据命令行来构成队列,ENQUEUE x 将编号为x的队员入队,若是队列中有x所属队伍的队员,则排在这些队员的最后面。DEQUEUE 出队,将队列中排第一位的出列并输出其对应编号。用vector模拟 不多说了。。#include #include #include #include #include using namespace std; const int MAXN=1000005; int a[MAXN]; vector q; int main() { int n... 阅读全文
posted @ 2013-05-04 19:15 Ink_syk 阅读(93) 评论(0) 推荐(0) 编辑