题意:一个序列,在其中一个数必须替换成给定数字p的条件下,求最大连续子序列之和。依次把每一个数替换成p,求每次的最大连续和,找出最大值。O(n^2)。#include #include #include #include typedef long long ll;using namespace st...
分类:
其他好文 时间:
2015-07-15 22:14:10
阅读次数:
110
两个类之间通信,不通过直接通信的方式,而是中间加一层类似于中介的类,中介者模式,就类比租房时找中介那会// Mediator.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include...
分类:
其他好文 时间:
2015-07-15 22:13:16
阅读次数:
141
DescriptionAlice and Bob decide to play a new stone game.At the beginning of the game they pick n(1#include#includeusing namespace std;int n,a[11];int...
分类:
其他好文 时间:
2015-07-15 22:10:37
阅读次数:
131
进程间通信-mmap
#include
void *mmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset);
int munmap(void *addr, size_t length);
mmap本质是把内存与硬盘上的文件同步。某块内存中的内容会同步到硬盘文件上,即把文件映射到内存。故通过对同一文件的读写达到进程间的通信。
参数解释:
addr:指定对哪儿块内存实行映射。NULL表示...
分类:
系统相关 时间:
2015-07-15 21:07:04
阅读次数:
219
题目链接
题意较为简单。
思路:
因为只有26个字母,所以用26棵线段树维护就好了,比较容易。
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
using namespace st...
分类:
其他好文 时间:
2015-07-15 21:06:45
阅读次数:
123
算是比较简单的二维费用背包了吧,注意在某一维上要求“装满”。另外:对于多维费用的背包,最内层的循环可以逆着写,想一想,为什么。 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 7 const int ...
分类:
其他好文 时间:
2015-07-15 20:57:12
阅读次数:
154
经典矩形嵌套问题,先排序再求LIS。需要注意在枚举j的时候x和y都要小于i才行。 1 #include 2 #include 3 using namespace std; 4 5 const int N = 1000; 6 int dp[N]; 7 8 struct Node 9 {10 ...
分类:
其他好文 时间:
2015-07-15 20:51:32
阅读次数:
102
做个实验,看一下成员变量的构造析构,父类子类的构造析构,以及虚函数对调用的影响。 1 #include 2 using namespace std; 3 4 class Member 5 { 6 public: 7 Member(int n):m_n1(n) 8 { 9 ...
分类:
编程语言 时间:
2015-07-15 20:46:31
阅读次数:
166
(i+1)*(j+1)=n+1转换成上面这个式子,也就是问n+1的因子有几个#include#include#include#includeusing namespace std;int main(){ int T; scanf("%d",&T); while(T--) { ...
分类:
其他好文 时间:
2015-07-15 20:45:35
阅读次数:
135
#include #include#include#include #define MAX_VERTEX_NUM 20 using namespace std;typedef struct ArcBox{ int tailVex, headVex;//该弧的尾和头顶点的位置 st...
分类:
其他好文 时间:
2015-07-15 20:42:16
阅读次数:
140