include

makefile、CmakeLists.txt使用小结

不羁岁月 提交于 2020-03-09 13:38:48
makefile 样例 CFLAGS += - O3 - Wall - std = c + + 11 LDLIBS += - lpthread - lopencv_core - lopencv_imgproc - lopencv_highgui \ - lOpenNI2 - lnvinfer - lnvparsers - lnvinfer_plugin - lnvonnxparser - lcudnn - lcublas - lcudart - lpthread INC_PATH += - I / usr / include / openni2 - I . - I . / Detector - I . / KeyPointDetector - I . / Spinnaker_carmer - I / home / zyy / Work / AIPoseDemo / TensorRT - 5.1 .5 .0 / include - I / usr / local / cuda / include - I / home / zyy / Work / AIPoseDemo / websocket_test / websocketpp - 0.8 .1 - I / usr / include / spinnaker LIB_PATH += - LOpenNI2 - L / usr /

习题6.8 整除问题(分解质因数)

流过昼夜 提交于 2020-03-09 12:50:17
很好的一道题。由于n最大1000,1000的阶乘过于大,故直接计算出来再判断整除次数肯定是不行。 于是就想到了把n和a都分解质因数,幂次分别保留在不同数组中,针对a的质因数找出n和a这些质因数的幂次,看整体上n的幂次为a的幂次的多少倍。具体来说这些质因数中n的幂次都是a的幂次的倍数,找出最小的倍数即可满足。 #include <cstdio> #include <iostream> #include <algorithm> #include <string> #include <cstring> #include <vector> #include <stack> #include <cctype> #include <cmath> #include <climits> using namespace std; const int MAXN = 1005; const int INF = INT_MAX; bool isPrime[MAXN]; vector<int> prime; int prime1num[MAXN]; int prime2num[MAXN]; void Initial(){ for(int i = 2; i < MAXN; i++){ isPrime[i] = true; } for(int i = 2; i < MAXN; i++){ if(!isPrime

用C++实现一个多进程回显服务器

纵然是瞬间 提交于 2020-03-09 04:42:10
用C++实现一个多进程回显服务器 1. 服务端程序(Linux) 服务进程:通过监听所有网卡的9877接口,当有客户端来连接时,使用fork创建一个子进程对客户端连接进行服务,然后父进程继续监听连接的到来 需要注意的是当服务进程未退出时,子进程在结束后将进入僵尸状态。服务父进程未使用信号对这些僵尸进程进行处理,随着连接的增多,服务端将出现很多僵尸进程。 当然,如果父进程退出,则其僵尸子进程将被过继给init进程(进程号为1),而init进程干的事情就是不断回收这些僵尸进程,系统将很快恢复正常。 tcpserv01.c : #include <netinet/in.h> // for htonl htons #include <sys/socket.h> // for socket bind listen accept #include <strings.h> // for bzero #include <unistd.h> // for close fork and so on #include <stdlib.h> // for exit #include <errno.h> // for errno #include <stdio.h> #include <string.h> #define SERV_PORT 9877 #define LISTENQ 1024 #define

PAT | A1026 Table Tennis(待优化)

可紊 提交于 2020-03-09 04:34:54
23分 # include <iostream> # include <vector> # include <queue> # include <algorithm> # include <climits> using namespace std ; struct Customer { int arriveTime ; int remainTime ; int waitTime ; bool vip ; bool serv ; } ; struct Table { int cusId ; int cusNum ; bool hasCus ; bool vip ; } ; bool cmp ( Customer a , Customer b ) { return a . arriveTime < b . arriveTime ; } vector < Customer > customers ; Table tables [ 100 ] ; int cus = 0 ; int n ; int serve ( int curTime , int tableNum ) { int minRemainTime = INT_MAX ; int curLastCum ; //当前时间到达的最后一位顾客的下一个的编号 for ( curLastCum = cus ; curLastCum < n

最短路 次短路 k短路(k很小)

蹲街弑〆低调 提交于 2020-03-09 04:11:45
最短路 luogu 3371 https://www.luogu.org/problemnew/show/P3371 1 #include <cstdio> 2 #include <cstdlib> 3 #include <cstring> 4 #include <queue> 5 #include <algorithm> 6 using namespace std; 7 const int maxn=1e4+10; 8 9 int dist[maxn]; 10 bool vis[maxn]; 11 12 struct node 13 { 14 int d,len; 15 ///相反 16 bool operator<(const node & b) const 17 { 18 return b.len<len; ///b.d放在左边,方便 19 } 20 }; 21 22 priority_queue<node> st;///这样写就可以了,省略后面的部分 23 vector<pair<int,int> >e[maxn]; 24 25 int main() 26 { 27 int n,m,s,x,y,z,d,i; 28 vector<pair<int,int> >::iterator j; 29 scanf("%d%d%d",&n,&m,&s); 30 for (i=1;i<=m

GCC参数介绍

China☆狼群 提交于 2020-03-09 02:24:13
gcc参数介绍 -x language filename 设定文件所使用的语言,而不是以后缀识别语言 -x none filename 关掉上个选项的语言设置,使用文件的后缀识别语言 -c 对文件进行预处理、编译和汇编,生成obj文件 gcc -c hello.c -C 在预处理的时候,不删除注释信息,一般用于分析程序 -S 只进行预处理和编译,生成汇编代码 gcc -S hello.c -E 只进行预处理,这个选项不生成文件,可以使用重定向或者-o选项使其生成一个文件 gcc -E hello.c -o hello.i -o 制定目标的名称,默认为a.out gcc -o hello hello.c -ansi 关闭gnu c中与ansi c不兼容的特性,激活ansi c的专有特性 -include file 包含某个代码,相当于在代码中使用#include gcc hello.c -include /usr/lib/hello.h -imacros file 将file中的宏加入到输入文件中 -Dmarco 相当于#define macro -Dmarco=defn 相当于#define macro=defn -Umacro 相当于#undef macro -Idir 对于#include“filename",gcc/g++会先在当前目录查找头文件

Linux下Nginx的HTTPS+多站点 虚拟主机配置

我与影子孤独终老i 提交于 2020-03-09 02:20:11
原文: Linux下Nginx的HTTPS+多站点 虚拟主机配置 阿里云产品通用代金券,最高可领1888元代金券分享一波 阿里云红包 . 阿里云的 购买入口 对于访问量不大的服务器,只运行一个网站会不会觉得有点浪费资源,或者说有多个网站要部署,但是只有一台服务器,能不能在一台主机上运行多个网站呢。当然是可以的,可以使用不同的目录区分不同的网站,这种方法好处是比较简单,但是会造成网站文件混乱,在使用框架时可能会产生冲突,使用虚拟主机可以方便的解决这个问题。 准备 一个已经备案的域名 一台有Nginx的服务器 ssl证书(不开启HTTPS可以忽略) 添加子域名。比如你注册的域名是 qiandu.com ,可以自己设置多个二级子域名比如 m.qiandu.com , api.qiandu.com 等等。以阿里云解析为例 记录值选择A,主机记录直接填写二级域名就行,比如二级域名是 m.qiandu.com ,只要填写 m 就行。记录值就是服务器ip了,然后确定就可以了。添加了域名后,可以去下载一个免费的ssl证书。 配置ssl证书。(不适用HTTPS可以跳过)把从阿里云下载的证书放到服务器上,一边都放在Nginx配置文件的目录中,比如 /etc/nginx ,在这个目录中新建一个目录,比如 ssl ,然后把证书放到这里。 注意,一定要有可读权限 配置Nginx。根据自己的具体情况

hadoop集群委任和解除节点

佐手、 提交于 2020-03-08 22:25:21
Hadoop集群经常需要添加节点或者从集群中移出故障节点。 委任新datanode 向集群添加datanode,需要通过hdfs的hdfs-site.xml的配置参数dfs.hosts来实现,然后启动datanode进程。 将源集群的配置文件拷贝至新节点待用。 在配置文件路径/opt/module/hadoop-2.6.0/etc/hadoop添加include.txt文件 # cat include.txt node4 master 在hdfs-site.xml中添加配置 <property> <name>dfs.hosts</name> <value>/opt/module/hadoop-2.6.0/etc/hadoop/include.txt</value> </property> 在namenode上刷新节点信息 $ hdfs dfsadmin -refreshNodes 修改slaves文件,添加新节点主机名 $ cat slaves node1 node2 node3 node4 master 启动新节点datanode $ hadoop-daemon.sh start datanode 通过web查看 解除节点 解除节点是通过dfs的hdfs-site.xml的配置参数dfs.hosts.exclude来实现,然后删除slaves文件中对应节点。

状压dp 持续更新

主宰稳场 提交于 2020-03-08 22:17:44
前置知识点:二进制状态压缩,动态规划。 1. AcWing 91 最短Hamilton路径 ( https://www.acwing.com/problem/content/93/ ) 给定一张 n 个点的带权无向图,点从 0~n-1 标号,求起点 0 到终点 n-1 的最短Hamilton路径。 Hamilton路径的定义是从 0 到 n-1 不重不漏地经过每个点恰好一次。 输入格式 第一行输入整数 n。 接下来 n行每行 n 个整数,其中第 i 行第 j 个整数表示点 i 到 j 的距离(记为a[i,j])。 对于任意的 x , y , z ,数据保证 a[x,x]=0,a[x,y]=a[y,x] 并且 a[x,y]+a[y,z]>=a[x,z]。 输出格式 输出一个整数,表示最短Hamilton路径的长度。 数据范围 1 ≤ n ≤ 20 0 ≤ a [ i , j ] ≤ 10 7 输入样例: 5 0 2 4 5 1 2 0 6 5 3 4 6 0 8 3 5 5 8 0 5 1 3 3 5 0 输出样例: 18 暴力跑一遍dfs: O(N*N*N!) 枚举n个点的全排列求最小值:O(N*N!). 分析: 在暴力的方法中,有一些重复计算存在,比如在计算路径1->2->3->4->5与路径1->2->4->3->5的长度时,我们重复计算了路径1->2的长度。

week2作业A

蓝咒 提交于 2020-03-08 21:18:13
题意:  东东有一张地图,想通过地图找到妹纸。地图显示,0表示可以走,1表示不可以走,左上角是入口,右下角是妹纸,这两个位置保证为0。既然已经知道了地图,那么东东找到妹纸就不难了,请你编一个程序,写出东东找到妹纸的最短路线。 Input输入是一个5 × 5的二维数组,仅由0、1两数字组成,表示法阵地图。Output:输出若干行,表示从左上角到右下角的最短路径依次经过的坐标,格式如样例所示。数据保证有唯一解。 Sample input 0 1 0 0 0 0 1 0 1 0 0 1 0 1 0 0 0 0 1 0 0 1 0 1 0 Sample output (0, 0) (1, 0) (2, 0) (3, 0) (3, 1) (3, 2) (2, 2) (1, 2) (0, 2) (0, 3) (0, 4) (1, 4) (2, 4) (3, 4) (4, 4) Hint坐标(x, y)表示第x行第y列,行、列的编号从0开始,且以左上角为原点。   另外注意,输出中分隔坐标的逗号后面应当有一个空格。 思路: 定义一个结构体,其中定义两个坐标x,y。通过bfs函数进行判断,定义x,y向上下左右进行进一步行进时,坐标的变化,定义一个记录行走过的标记数组,当走的坐标是未标记过且不是围墙且未走出边界时,将这个坐标进行标记,且将点进行push操作继续判断,直到走到目的地