Pow(x, n)
Total Accepted: 25273 Total
Submissions: 97470My Submissions
Implement pow(x, n).
题意:求x的n次幂
思路:二分法
n有可能是负的或正的
当n为负是,pow(x, n) = 1/pow(x, -n)
x^n = x^{n/2} *...
分类:
其他好文 时间:
2014-10-12 13:28:58
阅读次数:
169
问题详述:http://coursera.cs.princeton.edu/algs4/assignments/queues.htmlDequeue. A double-ended queue or deque (pronounced "deck") is a generalization of a...
分类:
其他好文 时间:
2014-10-12 13:17:48
阅读次数:
244
Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations:getandset.get(key)- Get the valu...
分类:
系统相关 时间:
2014-10-11 15:57:45
阅读次数:
260
N*M矩阵,从F点出发,走完所有的Y点,每走一格花费1点电量,走到G点时,电量充满,D不可到达,问起始时的最小满电量可以走完所有Y,Y和G一共最多15个
先BFS出所有的F,Y,G之间的最短距离。
然后二分起始电量,对每个电量,做状压DP判断是否可行
#include "stdio.h"
#include "string.h"
#include "queue"
using names...
分类:
其他好文 时间:
2014-10-11 15:01:35
阅读次数:
166
BFS:Is it possible that a solution exists using only one single queue? Yes, you bet. The single queue solution requires two extra counting variables w...
分类:
其他好文 时间:
2014-10-11 03:37:04
阅读次数:
190
利用线性表实现队列,为了有效利用空间,将其设计为循环结构,防止假溢出;牺牲一个存储单元以区分队空、队满。
设front队头,rear队尾,N为顺序表大小
队空:rear==front
队满:(rear+1)%N==front
#include
#define Elemtype int
#define N 100
struct Queue
{
Elemtype data[N];
int ...
分类:
其他好文 时间:
2014-10-11 01:38:34
阅读次数:
360
题目:LRU cacheDesign and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and set.get(key...
分类:
系统相关 时间:
2014-10-10 20:05:24
阅读次数:
357
Implementing a system call in Kernel 2.6.32 is somehow different fromthe method in Kernel 3.10.56.In kernel 2.6.32, we should register the system call...
分类:
其他好文 时间:
2014-10-10 07:04:24
阅读次数:
218
本章我们来了解下MSMQ的基本概念和开发过程。MSMQ全称MicroSoft Message Queue,微软消息队列,是在多个不同应用之间实现相互通信的一种异步传输模式,相互通信的应用可以分布于同一台机器上,也可以分布于相连的网络空间的任一位置。它的实现原理是:消息的发送者要把自己想要发送的信息放...
分类:
其他好文 时间:
2014-10-10 00:35:53
阅读次数:
729
题目链接:啊哈哈,选我选我思路是:相当于模拟约瑟夫环,仅仅只是是从顺逆时针同一时候进行的,然后就是顺逆时针走能够编写一个函数,仅仅只是是走的方向的标志变量相反。。还有就是为了(pos+flag+n-1)%n+1的妙用。。。题目:The Dole QueueIn a serious attempt t...
分类:
其他好文 时间:
2014-10-09 22:35:57
阅读次数:
226