上一页 1 ··· 12 13 14 15 16 17 18 19 20 ··· 34 下一页
摘要: 最大公约数,根据《编程之美》递归版写的非递归版:1. 对于y和x来说,如果y=k*y1, x = k * x1。那么有gcd(y,x)=k*gcd(y1, x1);2. 如果x=p*x1, p是素数(质数),并且y%p != 0,那么gcd(x, y) = gcd(p * x1, y) = gcd(... 阅读全文
posted @ 2014-09-15 12:23 linyx 阅读(129) 评论(0) 推荐(0) 编辑
摘要: 1。给个sorted array, 只包含不重复整数,数值范围在 [0,99]中间, 按格式打印其余数值:输入: [0,1,3,50,75]输出: [2,4-49,51-74,76-99]请写出程序,及 testing cases。 1 string findConsecutive(vector n... 阅读全文
posted @ 2014-09-14 20:57 linyx 阅读(154) 评论(0) 推荐(0) 编辑
摘要: 一个决定性问题C 若是为NPC,则代表它对NP是完备的,这表示:它是一个NP问题,且其他属于NP的问题都可归约成它。满足条件2(无论是否满足条件1)的问题集合被称为NP-hard。一个NP-hard问题至少跟NPC问题一样难。 有一类问题已经被证明属于NP-hard但不属于NP,即,这类问题至少与N... 阅读全文
posted @ 2014-09-14 17:10 linyx 阅读(436) 评论(0) 推荐(0) 编辑
摘要: 7.4Write methods to implement the multiply, subtract, and divide operations for integers. Use only the add operator.比较简单。但是要封装得好。7.5 Given two squares... 阅读全文
posted @ 2014-09-14 10:06 linyx 阅读(175) 评论(0) 推荐(0) 编辑
摘要: 哲学家进餐问题:(1) 在什么情况下5 个哲学家全部吃不上饭?考虑两种实现的方式,如下:A.算法描述: 1 void philosopher(int i) {/*i:哲学家编号,从0 到4*/ 2 while (TRUE) { 3 think( ); /*哲学家正在思考*/ ... 阅读全文
posted @ 2014-09-13 13:16 linyx 阅读(306) 评论(0) 推荐(0) 编辑
摘要: 读写锁是用来解决读者写者问题的,读操作可以共享,写操作是排他的,读可以有多个在读,写只有唯一个在写,同时写的时候不允许读。互斥锁与读写锁的区别:当访问临界区资源时(访问的含义包括所有的操作:读和写),需要上互斥锁;当对数据(互斥锁中的临界区资源)进行读取时,需要上读取锁,当对数据进行写入时,需要上写... 阅读全文
posted @ 2014-09-13 10:51 linyx 阅读(321) 评论(0) 推荐(0) 编辑
摘要: 今年看到一篇文章还是很受启发。If you have the guts to start selling what you believe in, customers who share your perspective will join in the cause. Not everyone wi... 阅读全文
posted @ 2014-09-08 16:48 linyx 阅读(214) 评论(0) 推荐(0) 编辑
摘要: In computer science, functional programming is a programming paradigm, a style of building the structure and elements of computer programs, that treat... 阅读全文
posted @ 2014-09-08 16:27 linyx 阅读(262) 评论(0) 推荐(0) 编辑
摘要: 今年汤姆斯杯的时候,大马进了决赛,拿督很漂亮地拿了第一分,后面几场大马打得不好,输了。拿督无限接近于汤杯冠军。世锦赛刚刚结束,拿督0:2不敌谌怂,再次与冠军失之交臂。每次看完羽毛球赛,心情都不好。只是,比赛结束,该喜欢谁,还喜欢谁。 阅读全文
posted @ 2014-09-01 00:23 linyx 阅读(102) 评论(0) 推荐(0) 编辑
摘要: n个数字(0,1,…,n-1)形成一个圆圈,从数字0开始,每次从这个圆圈中删除第m个数字(第一个为当前数字本身,第二个为当前数字的下一个数字)。当一个数字删除后,从被删除数字的下一个继续删除第m个数字。求出在这个圆圈中剩下的最后一个数字。这个问题在wiki上叫约瑟夫斯问题。一开始的序列是S(n): ... 阅读全文
posted @ 2014-08-20 00:34 linyx 阅读(285) 评论(0) 推荐(0) 编辑
上一页 1 ··· 12 13 14 15 16 17 18 19 20 ··· 34 下一页