上一页 1 ··· 3 4 5 6 7 8 9 下一页
2011年4月10日

zoj2741Offside

摘要: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1741只能用一个词来形容--“恶心”数据里有double#include<iostream>#include<stdio.h>#include<string>#include<vector>#include<sstream>using namespace std;struct node{ double x,y;};node change(string s){ node a; int it=s.find(',& 阅读全文
posted @ 2011-04-10 11:50 4.5.6 阅读(175) 评论(0) 推荐(0) 编辑
2011年4月3日

zoj2972Hurdles of 110m

摘要: dp[i][j]表示在第i段赛道能量为j时所耗最短时间(i=0为第一段)#include<iostream>#include<stdio.h>#include<algorithm>using namespace std;int m,n,ans;int t1[111],t2[111],t3[110],f1[111],f2[111],dp[111][111];const int INF=100000000;int main(){ int cas; scanf("%d",&cas); while(cas--) { scanf(" 阅读全文
posted @ 2011-04-03 23:50 4.5.6 阅读(153) 评论(0) 推荐(0) 编辑
2011年4月2日

UVa193Graph Coloring

摘要: DFS 题意:相邻的节点不能都涂成黑色,问是黑色节点最多的方案(只能选择黑和白)#include<iostream>#include<cstring>#include<stdio.h>using namespace std;int G[101][101],black[101],ANS[101];int n,m,ans;void DFS(int cur,int w)//cur当前要处理的节点,当前已有白色节点个数{ if(w>=n-ans)return;//白色节点多于最优情况下白色节点时 if(cur==n+1) { ans=n-w; for(int 阅读全文
posted @ 2011-04-02 16:51 4.5.6 阅读(183) 评论(0) 推荐(0) 编辑

UVa729 The Hamming Distance Problem

摘要: 求输出所有 含h个1的且长度为n的01串可重集全排列 集合为{1,0} #include<iostream>#include<stdio.h>using namespace std;int cas,n,h;int tmp[17];void DFS(int cur,int num){ if(num>h)return; if(cur==n) { if(num==h) { for(int i=0;i<n;i++) printf("%d",tmp[i]); printf("\n"); } return; } for(int i 阅读全文
posted @ 2011-04-02 14:27 4.5.6 阅读(247) 评论(0) 推荐(0) 编辑
2011年4月1日

zjut1624序列问题

摘要: http://acm.zjut.edu.cn/ShowProblem.aspx?ShowID=1624这是去年校赛得题目,作为当时的fresh man我们水水地硬是人工枚举把答案暴力出来了,今天回过头来写,感觉大不一样了!一道简单的DFS#include<iostream>using namespace std;int n,num;void dfs(int k,int tmp,int last,int c)//k表示接下来要在k与k+1中间进行处理,tmp当前获得值,last表示最后一次加上或减去的数,c表示最后一次进行的运算 ,1表示‘+’,0表示‘-’ { if(n==k){i 阅读全文
posted @ 2011-04-01 13:10 4.5.6 阅读(235) 评论(0) 推荐(0) 编辑
2011年3月31日

悲剧的矩阵乘法

摘要: 今天学习矩阵乘法,结果程序一直超栈。唯一的收获就是二分计算 n^m 结果mod10^9#include<iostream>using namespace std;int m,n;long long int pow(int k){ if(k==1)return m; else if(k%2)return pow(k-1)*m; else { long long int mm=pow(k/2); return (mm%1000000000)*(mm%1000000000)%1000000000; }}int main(){ while(cin>>m>>n) { 阅读全文
posted @ 2011-03-31 22:36 4.5.6 阅读(178) 评论(0) 推荐(0) 编辑
2011年3月27日

找到搜索的北了

摘要: 终于理解搜索其实是一种变相的暴力,DFS的根源就是 全排列+剪枝(个人理解,可能以后题目做多了 观点还会变)原来 在寒假里看《算法竞赛入门经典》,看到6.4.2的走迷宫 云里雾里,原来它就是BFS的基础,当时看到暴力那章里说到隐式图,真的觉得好抽象,现在有点理解了,它应该算是有图到没图的变身。我还是很畏惧搜索 尤其是DFS,看来我还有相当长的一段路要走啊,革命尚未成功,同志还需努力!! 阅读全文
posted @ 2011-03-27 11:19 4.5.6 阅读(144) 评论(0) 推荐(0) 编辑

hdu 1584 蜘蛛牌

摘要: 思路:下面写的算清楚了,其实这道题就是对移动牌的先后顺序进行枚举(全排列,当然要剪枝),然后对于每张牌移动的位置进行寻找在别的地方 还看到了DP的做法 还有二分的思想Problem : 1584 ( 蜘蛛牌 ) Judge Status : AcceptedRunId : 3716782 Language : C++ Author : zjut11018Code Render Status : Rendered By HDOJ C++ Code Render Version 0.01 Beta#include<iostream>#include<cmath>#inclu 阅读全文
posted @ 2011-03-27 11:03 4.5.6 阅读(1810) 评论(1) 推荐(0) 编辑
2011年3月26日

hdu: 1426 ( Sudoku Killer )

摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1426Problem : 1426 ( Sudoku Killer ) Judge Status : AcceptedRunId : 3712414 Language : C++ Author : zjut11018Code Render Status : Rendered By HDOJ C++ Code Render Version 0.01 Beta借助此题学习DFS思路:把需要填数的位置保存到q中,再递归求解#include<iostream>using namespace std;int 阅读全文
posted @ 2011-03-26 17:17 4.5.6 阅读(727) 评论(0) 推荐(0) 编辑

hdu 1372 ( Knight Moves ) BFS

摘要: /*不停地BFS 我发现BFS的题目泛滥了*/Problem : 1372 ( Knight Moves ) Judge Status : AcceptedRunId : 3710302 Language : C++ Author : zjut11018Code Render Status : Rendered By HDOJ C++ Code Render Version 0.01 Beta#include<iostream>#include<queue>#include<string>using namespace std;int dir[8][2]={ 阅读全文
posted @ 2011-03-26 13:51 4.5.6 阅读(367) 评论(0) 推荐(0) 编辑
上一页 1 ··· 3 4 5 6 7 8 9 下一页