随笔分类 -  ACM

leetcode Missing Number
摘要:Given an array containingndistinct numbers taken from0, 1, 2, ..., n, find the one that is missing from the array.For example,Givennums=[0, 1, 3]retur... 阅读全文

posted @ 2015-08-24 09:17 asif 阅读(263) 评论(0) 推荐(0)

统治世界的十大算法
摘要:什么是算法?通俗而言,算法是一个定义明确的计算过程,可以一些值或一组值作为输入并产生一些值或一组值作为输出。因此算法就是将输入转为输出的一系列计算步骤。—Thomas H. Cormen,Chales E. Leiserson,算法入门第三版简而言之,算法就是可完成特定任务的一系列步骤,它应该具备三... 阅读全文

posted @ 2014-06-19 18:52 asif 阅读(171) 评论(0) 推荐(0)

CodingTrip - 携程编程大赛 (预赛第二场)第一题
摘要:剪刀石头布Time Limit : 2000/1000ms (Java/Other)Memory Limit : 32768/32768K (Java/Other)Total Submission(s) : 4Accepted Submission(s) : 1Font:Times New Roman|Verdana|GeorgiaFont Size:←→Problem Description现有M个人一起玩剪刀石头布,以1-M编号,每人出一种,出过不再改变,但是我们并不知道它到底是哪一种。 (其中石头赢剪刀,剪刀赢布,布赢石头,一样则平)裁判用两种说法对这M个人所构成的输赢关系进行描述:一: 阅读全文

posted @ 2014-04-12 09:23 asif 阅读(457) 评论(0) 推荐(1)

CodingTrip - 携程编程大赛 (预赛第一场)第四题
摘要:旋转的二进制Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2119Accepted Submission(s): 339Problem Description给定一个自然数M,及其二进制长度N,得到一个N位的二进制串b1 b2 ... bN-1 bN将该串做左旋转,即b1移到bN后面,得到一个新的二进制串:b2 b3 ... bN-1 bN b1对新的二进制串再做左旋转,得二进制串b3 b4 ... bN-1 bN b1 ... 阅读全文

posted @ 2014-04-11 09:26 asif 阅读(287) 评论(0) 推荐(0)

CodingTrip - 携程编程大赛 (预赛第一场)第三题
摘要:携程全球数据中心建设Time Limit: 10000/5000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 725Accepted Submission(s): 307Problem Description携程为了扩展全球在线旅游业务,决定在全球建设多数据中心,以便提高网站的访问速度和容灾处理。为了实现每个数据中心的数据能互通,数据中心之间需要通过光纤连接。为了节约光纤成本,我们计划采用点对点方式来达到最终各个数据中心的数据互通,每个数据中心本身都可以作为数据中转站。做为全球多数据 阅读全文

posted @ 2014-04-11 08:55 asif 阅读(298) 评论(0) 推荐(0)

约瑟夫环求最后剩余的元素
摘要:递推公式f[1]=0;f[i]=(f[i-1]+m)%i; (i>1)# include# include# include# include# include# includeusing namespace std;# define maxn 1000001int main(){ int n,m; while(cin>>n>>m) { int ans=0; for(int i=2;i<=n;i++) ans=(ans+m)%i; printf("%d\n",ans+1); } return 0;}View ... 阅读全文

posted @ 2014-02-26 10:29 asif 阅读(255) 评论(0) 推荐(0)

nbuoj 1537 Travel
摘要:[1537] Travel时间限制: 2000 ms 内存限制: 65535 K问题描述One time, group master organized nekoTeam to travel, he always send a person to toilet before arriving a scene, and the rest of the people continued to move forward.The scenes are numbered from 1 to n, nekoTeam was going from scene 1 to scene n.输入The first 阅读全文

posted @ 2014-01-29 21:11 asif 阅读(860) 评论(0) 推荐(0)

nbuoj 1532 New String
摘要:[1532] New String时间限制: 2000 ms 内存限制: 65535 K问题描述Ceil so love the new string.If you can erase any character from the string, and use the remain character by any order to comprise the "new" , the string is the new string, otherwise not.Give you some string, you should help Ceil determine whe 阅读全文

posted @ 2014-01-29 18:31 asif 阅读(973) 评论(0) 推荐(0)

导航