随笔分类 -  堆栈

摘要:/*调用算法中函数求写一个排序*/#include #include#include#include#include#include#include#includeusing namespace std;#define maxn 2600000typedef int State[9];State st[maxn],goal;int dist[maxn];const int dx[]= {-1,1,0,0};const int dy[]= {0,0,-1,1};int vis[36288],fact[9];/*void init_lookup_table(){ int i; fact... 阅读全文
posted @ 2013-07-25 20:31 myth_HG 阅读(222) 评论(0) 推荐(0)
摘要:#include #include#include#include#include#include#include#includeusing namespace std;#define LL long longconst int MAXN = 1000+10;int n,target[MAXN];int main(){ while(~scanf("%d",&n)) { stack s; int A=1,B=1,i; for(i =1 ;i<=n;i++) scanf("%d",&target[i]); i... 阅读全文
posted @ 2013-07-19 15:27 myth_HG 阅读(282) 评论(0) 推荐(0)
摘要:/*Problem D Time Limit : 2000/1000ms (Java/Other) Memory Limit : 32768/32768K (Java/Other)Total Submission(s) : 21 Accepted Submission(s) : 3Problem Description 对给定的字符串(只包含'z','o','j'三种字符),判断他是否能AC。是否AC的规则如下:1. zoj能AC;2. 若字符串形式为xzojx,则也能AC,其中x可以是N个'o' 或者为空;3. 若azbjc 能 阅读全文
posted @ 2012-11-16 23:08 myth_HG 阅读(359) 评论(0) 推荐(0)
摘要:#include<iostream>#include<stdio.h>#include<stack>using namespace std;char Compare(char x,char y){ char c[][8]={">><<<>>", ">><<<>>", ">>>><>>", ">>>><>>", &q 阅读全文
posted @ 2012-08-03 17:02 myth_HG 阅读(481) 评论(0) 推荐(0)
摘要:#include<iostream>#include<stack>using namespace std;void BracketMatch(char *str){ stack<char> S; char ch; int i; for(i=0;str[i]!='\0';i++) { switch(str[i]) { case'(': case'[': case'{': S.push(str[i]); break; case')': ... 阅读全文
posted @ 2012-08-02 16:34 myth_HG 阅读(344) 评论(0) 推荐(0)
摘要:#include<iostream>#include<stack>using namespace std;void Conversion (int N){ int x; stack<int> s; if(N==0) { printf("%d\n",0); return ; } while(N>0) { x=N%2; s.push(x); N=N/2; } while(!s.empty()) { x=s.top(); printf("%d",x); s.pop(); } printf("\n") 阅读全文
posted @ 2012-08-02 14:17 myth_HG 阅读(418) 评论(0) 推荐(0)
摘要:Problem F Time Limit : 5000/1000ms (Java/Other) Memory Limit : 32768/32768K (Java/Other)Total Submission(s) : 4 Accepted Submission(s) : 4Font: Times New Roman | Verdana | Georgia Font Size: ← →Problem Description四月一日快到了,Vayko想了个愚人的好办法——送礼物。嘿嘿,不要想的太好,这礼物可没那么简单,Vayko为了愚人,准备了一堆盒子,其中有一个盒子里面装了礼物。盒子里... 阅读全文
posted @ 2012-08-01 17:55 myth_HG 阅读(313) 评论(0) 推荐(0)
摘要:/*Problem ETime Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other)Total Submission(s) : 1 Accepted Submission(s) : 1Font: Times New Roman | Verdana | GeorgiaFont Size: ← →Problem DescriptionMatrix multiplication problem is a typical example of dynamical programming.Suppose you 阅读全文
posted @ 2012-07-29 20:14 myth_HG 阅读(270) 评论(0) 推荐(0)