上一页 1 ··· 16 17 18 19 20 21 22 23 24 ··· 47 下一页

2013年12月10日

摘要: Graham扫描法求凸包的模板运行之后可以得到存有凸包顶点的栈s和栈顶指针top,n代表总点数这个模板我当时调了很久,主要难点有两个,一个是正确的极角排序,一个是出栈入栈的细节操作,逆时针扫描,这里注意栈内元素不能少于三个,新的点在当前线的顺时针方向就出栈,逆时针入栈这个算法总体来讲还是简单易懂的,... 阅读全文
posted @ 2013-12-10 15:00 LegendaryAC 阅读(1317) 评论(0) 推荐(0) 编辑
 
摘要: 最长公共子序列的记忆化搜索模板a,b数组分别存两个字符串,dp数组初始化为-1s1表示a串起始地址,e1表示a串结束地址+1,s2、e2同理表示b串int LCS(int s1,int e1,int s2,int e2){ if(dp[s1][s2]!=-1) return dp[s1][s2] ; if(s1==e1 || s2==e2) return dp[s1][s2]=0 ; if(a[s1]==b[s2]) return dp[s1][s2]=1+LCS(s1+1,e1,s2+1,e2) ; else ... 阅读全文
posted @ 2013-12-10 14:07 LegendaryAC 阅读(190) 评论(0) 推荐(0) 编辑

2013年12月7日

摘要: http://acm.hdu.edu.cn/showproblem.php?pid=2268小学四年级应用题,让我找回了儿时的快乐。。。#include #include #include using namespace std ;int main(){ int a,b,c ; while(~scanf("%d%d%d",&a,&b,&c)) { if(b<=a) { printf("%.3lf\n",c*1.0/a) ; continue ; } double x=c*1.0... 阅读全文
posted @ 2013-12-07 23:30 LegendaryAC 阅读(160) 评论(0) 推荐(0) 编辑
 
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=2273N辆车排队过马路,不能相撞,问最短时间ans=车的总长度/最小速度#include using namespace std ;int main(){ int n ; while(~scanf("%d",&n)) { int minn=10 ; int a,b ; int cnt=0 ; while(n--) { scanf("%d%d",&a,&b) ; cnt+=a ; ... 阅读全文
posted @ 2013-12-07 00:56 LegendaryAC 阅读(201) 评论(0) 推荐(0) 编辑

2013年12月4日

摘要: 迪杰斯特拉算法重点是松弛操作,解释为用一个dis数组记录从起点走到当前点的最短距离,如果当前点的dis值加上走到相邻点的距离小于相邻点的dis值,则更新相邻点的dis为前面两数之和。之后不断维护dis的值直到终点。实现方面可以用优先队列不断取出dis值小的点,到终点结束。head提前全置为-1,无向... 阅读全文
posted @ 2013-12-04 10:52 LegendaryAC 阅读(196) 评论(0) 推荐(0) 编辑

2013年11月27日

摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1098假设x=m时,65|f(m),即65|5*m^13+13*m^5+k*a*m计算f(m+1)=(5*m^13+13*m^5+k*a*m)+65*(m^12+6*m^11+22*m^10+55*m^9+99*m^8+132*m^7+132*m^6+99*m^5+56*m^4+24*m^3+8*m^2+2*m)+(18+k*a)式子的前两部分显然能被65整除,此时如果65|(18+k*a),那么65|f(m+1)。同时观察到f(1)=18+k*a,所以如果65|f(1),则65|f(m+1),此时对于所有x 阅读全文
posted @ 2013-11-27 12:28 LegendaryAC 阅读(267) 评论(0) 推荐(0) 编辑

2013年11月25日

摘要: http://acm.hdu.edu.cn/showproblem.php?pid=4121中国象棋的简单模拟,给出黑方仅存的老帅坐标,再给出红方棋子坐标,问是否把黑方将死。输入数据有多余空格,所以要用cin,不能用scanf,这块错惨了#include using namespace std ;int abs(int x){ return x>0?x:-x ;}char map[11][11] ;int dir[4][2]={{1,0},{-1,0},{0,1},{0,-1}} ;int RGX,RGY ;int xx,yy ;int ok(int x,int y){ if(y!... 阅读全文
posted @ 2013-11-25 20:25 LegendaryAC 阅读(440) 评论(0) 推荐(0) 编辑

2013年11月16日

摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1033这题的题干说的很绕,结合样例不难理解题意,走折线,A代表顺时针,V代表逆时针,给一个包含A和V的字符串,输出走过的点。不难发现,不管是顺时针走还是逆时针走,x和y坐标的变化都是不一定的。而根据折线的特点我们知道单纯的向一个方向走的周期是4,沿着这个思路模拟出坐标变化就容易多了#include #include using namespace std ;char a[2001] ;int sx,sy ;int flag ;int len ;int main(){ while(~scanf("%s 阅读全文
posted @ 2013-11-16 20:03 LegendaryAC 阅读(307) 评论(0) 推荐(0) 编辑

2013年11月14日

摘要: http://acm.hdu.edu.cn/showproblem.php?pid=2102中文题,开始以为要时间恰好,写个dfs超时,加个奇偶剪枝还超时,然后疯了问了sx,知道要小于等于那个时间就可以,当时吐血到了传送点必须传送有个trick是从'#'跳到'#'这种情况不能走#include #include using namespace std ;typedef struct L{ int x,y,f ; int step ;}L ;int n,m,t ;char map[2][11][11] ;int vis[2][11][11] ;int dir[4] 阅读全文
posted @ 2013-11-14 17:50 LegendaryAC 阅读(751) 评论(0) 推荐(0) 编辑

2013年11月13日

摘要: 答:多练。 阅读全文
posted @ 2013-11-13 20:11 LegendaryAC 阅读(173) 评论(0) 推荐(0) 编辑
上一页 1 ··· 16 17 18 19 20 21 22 23 24 ··· 47 下一页