在进行多线程编程时,我们总会遇到全局变量和数据结构的问题,这是多线程之间进行通信的问题。如果多个线程同时读写一个全局变量,那么会造成竞争或者出错。为了解决这一问题,我们需要对全局数据进行,使用互斥量实现锁的机制,当某个线程在某个操作前进行了加锁,那么某个操作只能在这个线程进行,直至将锁去除,相当于在这里将多线程的并行变成了串行。本文重点学习如何使用互斥量进行全局数据的同步,分为三个部分,第一部分给...
分类:
其他好文 时间:
2014-08-13 19:02:47
阅读次数:
130
n个数随机等概率的抽样m个,提供了4种方案的算法。...
分类:
其他好文 时间:
2014-08-13 19:01:57
阅读次数:
193
memory子系统设定cgroup中任务使用的内存限制,并自动生成那些任务使用的内存资源报告。memory子系统是通过
linux的resource counter机制实现的,在进程进行内存分配、释放时对进程进行charge、uncharge操作。
charge操作进行点:
1.分配新页框时(请求调页、copy on write),在do_falut,do_anonymous_pag...
分类:
其他好文 时间:
2014-08-13 19:01:27
阅读次数:
199
Problem Description
“Ladies and Gentlemen, It’s show time! ”
“A thief is a creative artist who takes his prey in style... But a detective is nothing more than a critic, who follows our footsteps.....
分类:
其他好文 时间:
2014-08-13 19:01:17
阅读次数:
210
Catch That Cow
Time Limit: 2000MS
Memory Limit: 65536K
Total Submissions: 46715
Accepted: 14673
Description
Farmer John has been informed of the location of a fugitiv...
分类:
其他好文 时间:
2014-08-13 19:00:57
阅读次数:
230
0 1 2 3 4 5 6 7 8 //下标
{ 9 , 4 , 3 , 7 , 3 , 8 , 2 , 4 , 8 }//通过mergesort函数递归 来切 开始的时候fir=0, las=8, mid=4 所以下标0-4,分为前组 5-8分为后组
{ 9 , 4 , 3 , 7 , 3 }{ 8 , 2 , 4 , 8 }
{ 9 , 4 , 3 }{...
分类:
其他好文 时间:
2014-08-13 19:00:47
阅读次数:
160
先贴自己类比二维树状数组写的三维树状数组模板: 开始的时候循环体内j=y,k=z,没写,以为自己思路错了,,,hehe.....
更高维的树状数组以此类比
const int MAXN = 100+10;
int c[MAXN][MAXN][MAXN];int X,Y,Z;
int N;
inline int lowbit(int x){return x&(-x);}
void up...
分类:
其他好文 时间:
2014-08-13 19:00:37
阅读次数:
189
Apache Hadoop 2.5.0是一个在2.x.y发布线上的一个小版本,建立在之前稳定的发布版本2.4.1之上。
主要特性和改进:
1. Common
a) 使用HTTP代理服务器时认证改进。当通过代理服务器使用WebHDFS时这是非常有用的。
b) 增加了一个新的Hadoop指标监控sink,允许直接写到Graphite。
c)...
分类:
其他好文 时间:
2014-08-13 19:00:17
阅读次数:
278
Pixel ? Point Conversion
Table...
分类:
其他好文 时间:
2014-08-13 19:00:00
阅读次数:
373
poj2185 Milking Grid(KMP运用)...
分类:
其他好文 时间:
2014-08-13 18:59:47
阅读次数:
123
求最大的k 使得 m^k 能被n!整除
m^k就是让m的每个质因子个数增加了k倍,只要求得n!的质因子能让m增加多少倍就够了。当然这里要取增加倍数最少的。
木桶装水的量取决于最短的木板。
预处理2-n每个数的质因子情况,由于n有10000,前10000个素数有1000+个,所以维护前缀和不划算。
case只有500 所以干脆每次都算一遍。
#include
#include
#inc...
分类:
其他好文 时间:
2014-08-13 18:59:37
阅读次数:
183
蓝牙4.0 BLE 入门
1. 手机需要android 4.3 及以上版本
2. 权限:
只允许支持BLE 的手机安装还需要添加uses-feature
3. BLE 设备扫描
3.1 获取蓝牙适配器: mBluetoothAdapter = bluetoothManager.getAdapter();
3.2 开始扫描: mBluetoothAdapter.st...
分类:
其他好文 时间:
2014-08-13 18:59:17
阅读次数:
615
Problem Description
In the game of DotA, Pudge’s meat hook is actually the most horrible thing for most of the heroes. The hook is made up of several consecutive metallic sticks which are of the same...
分类:
其他好文 时间:
2014-08-13 18:59:07
阅读次数:
226
中文题,题意不再累赘。
思路:对于第 i 行的放士兵,影响它的只有第 i-1 行和 i-2 行,所以暴力枚举符合这三行的状态
state[i],state[j],state[k]. 接下来就是二进制的巧妙应用了。
具体题解看代码注释!!!
#include
#include
#include
#include
#include
#include
#inc...
分类:
其他好文 时间:
2014-08-13 18:58:37
阅读次数:
205
Enctype是指定将数据回发到服务器时浏览器使用的编码类型,其编码类型有以下三种
一、application/x-www-form-urlencoded
这是通过表单发送数据时默认的编码类型。我们没有在from标签中设置enctype属性时默认就是application/x-www-form-urlencoded类型的。application/x-www-form-urlencoded编...
分类:
其他好文 时间:
2014-08-13 18:58:17
阅读次数:
170
一道用到优先队列的BFS题目
#include
#include
#include
#include
#include
#define N 201
using namespace std;
char maze[N][N];
int a,b,anw;
bool visit[N][N];
int dir[4][2]={{0,1},{1,0},{-1,0},{0,-1}};
int sx,s...
分类:
其他好文 时间:
2014-08-13 18:57:47
阅读次数:
201