复试机试之2005-2011年浙江大学计算机及软件工程研究生机试真题.docxVIP

复试机试之2005-2011年浙江大学计算机及软件工程研究生机试真题.docx

  1. 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
  2. 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  3. 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
  4. 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
  5. 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们
  6. 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
  7. 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
复试机试之2005年浙江大学计算机及软件工程研究生机试真题 (2012-02-04 18:09:24) 转载▼ 切标签: 分类:複試機試 终于搞懂了最长子段和,并查集终于也写对了, 05年浙江大学道题目搞定。 第二道的dp解法,在dp以外的正常思路的解法,第三道的并查集的动手写,第五道 struct排序,对于自己的提高都是很有价值的,要重点注意。 Problem 1 : A+B 计算A+B,只不过A和B的每一位数字由对应英文给出。直接按要求解析计算, 通过。 #in clude iostream #in clude stri ng using n ames pace std; string flag[]={zero,o ne,two,three,four,five,six,seve n,”eight, nin e,+,=}; int mai n(){ stri ng tmp; int res,a,b,i ndex; while(true){ a=b=0; while(ci nt mptm p!=flag[10]){ for(i ndex=0;i ndex10;i ndex++) if(tmp==flag[i ndex]){ a=a*10+in dex; break; } } while(ci nt mptmp!=flag[11]){ for(i ndex=0;i ndex10;i ndex++) if(tmp==flag[i ndex]){ b=b*10+in dex; break; } } res=a+b; if(res==0) break; coutrese ndl; } return 0;} Problem 2 :最大连续子序列 就是求最大子段和,然后顺便给出该连续序列的首尾元素,如果序列不唯一,输出起 始序号最小的那个。 参考编程之美, 终于把只会用代码而没完全掌握的东西完全弄懂了, 也不错。 1 次通过。 #include stdio.h #include iostream using namespace std; const int MAXN=10010; int in[MAXN],start[MAXN]; int max(int a,int b){ return ab?a:b; } int main(){ int index,alln,num,tmp; while(scanf(%d,num)==1num!=0){ for(index=0;indexnum;index++) scanf(%d,in[index]); start[index-1]=in[index-1]; alln=in[index-1]; for(index=num-2;index=0;index--){ start[index]=max(in[index],in[index]+start[index+1]); alln=max(alln,start[index]); } if(alln0){ printf(0 %d %d\n,in[0],in[num-1]); }else{ printf(%d,alln); for(index=0;indexnum;index++){ if(start[index]==alln){ printf( %d,in[index]); tmp=alln; do{ tmp-=in[index]; index++; }while(tmp!=0); printf( %d\n,in[index-1]); break; } } } } return 0;} Problem 3 :畅通工程 说白了就是求连通分量的数目, 可以用 dfs 来做, 什么时候谢谢。 但是比较想练习下并 查集,结果写错了两次,不过也好,要用得对还是靠错误堆起来的,虽然错误很有意义,不 过能一次完全理解正确更好。 3 次通过。 错误在于 union 函数写错了无数次。 #include stdio.h #include iostream #include algorithm using namespace std; const int MAXN=1010; int parent[MAXN]; int collapsingFind(int i){ int index,tmp,root; root=i; while(parent[root]!=root) root=parent[root]; index=i; while(parent[index]!=root){ tmp=parent[index]; parent[index]=root; index=tmp; } return root; } void unionR(int a,int b){ int ra,r

文档评论(0)

jinchenl + 关注
实名认证
文档贡献者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档