kk Blog —— 通用基础


date [-d @int|str] [+%s|"+%F %T"]
netstat -ltunp
sar -n DEV 1

eclipse生成jar包

第一:普通类导出jar包

普通类就是指此类包含main方法,并且没有用到别的jar包。
1.在eclipse中选择你要导出的类或者package,右击,选择Export子选项;
2.在弹出的对话框中,选择java文件—选择JAR file,单击next;
3.在JAR file后面的文本框中选择你要生成的jar包的位置以及名字,注意在Export generated class files and resources和Export java source files and resources前面打上勾,单击next;
4.单击两次next按钮,到达JAR Manifest Specification。注意在最底下的Main class后面的文本框中选择你的jar包的入口类。单击Finish,完成。

运行 java -jar 名字.jar,检测运行是否正确。

第二、你所要导出的类里边用到了别的jar包。

比如说你写的类连接了数据库,用到数据库驱动包oracl.jar.。
1.先把你要导出的类按照上面的步骤导出形成jar包,比如叫test.jar
2.新建一个文件夹main,比如在D盘根目录下;
3.把test.jar和oracl.jar拷贝到main文件下,右击test.jar,解压到当前文件夹。把META-INF\MANIFEST.MF剪切到另外一个地方 (比如是桌面!) ;
4.右击oracl.jar,解压到当前文件夹。
5.在dos环境下,进入到D盘的main文件夹下,执行 jar cvfm new.jar meta-inf/manifest.mf .,不要忘了最后面的点。
6.用压缩工具打开你新生成的new.jar,用你放在桌面的META-INF\MANIFEST.MF覆盖new.jar原有。

运行 java -jar 名字.jar,检测运行是否正确。

统计git提交行数的脚本

可以保存为count.sh运行 ./count.sh your_name

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/bin/sh
insert=0
delete=0
git log --author=$1 --since "2022-01-01" --shortstat --pretty=format:"" application/ | sed /^$/d > /tmp/tmp.count

while read line ;do
current=`echo $line | awk -F ',' '{printf $2}' | awk '{printf $1}'`
insert=`expr $insert + $current`
current=`echo $line | awk -F',' '{printf $3}' | awk '{printf $1}'`
if [ "$current" != "" ]; then
	delete=`expr $delete + $current`
fi
done < /tmp/tmp.count

echo $1 $insert insertions, $delete deletions

异或值最大

http://acm.hust.edu.cn:8080/judge/problem/viewProblem.action?id=18669

http://acm.sgu.ru/problem.php?contest=0&problem=275

275. To xor or not to xor

time limit per test: 0.5 sec.
memory limit per test: 65536 KB

input: standard
output: standard

The sequence of non-negative integers A1, A2, …, AN is given. You are to find some subsequence Ai1, Ai2, …, Aik(1 <= i1< i2< … < ik<= N) such, that Ai1XOR Ai2XOR … XOR Aikhas a maximum value.

Input

The first line of the input file contains the integer number N (1 <= N <= 100). The second line contains the sequence A1, A2, …, AN (0 <= Ai <= 1018).

Output

Write to the output file a single integer number – the maximum possible value of Ai1XOR Ai2XOR … XOR Aik.

Sample test(s)
Input

3 11 9 5

Output

14

从n个数中选出若干个使得异或的值最大

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include<stdio.h>
#include<iostream>
#include<queue>
using namespace std;
priority_queue<__int64> q;
int main() {
	int n;
	__int64 ans, pre, i;
	while (scanf("%d", &n) != EOF) {
	    while (n--) {
	        scanf("%I64d", &i);
	        q.push(i);
	    }
	    ans = 0;
	    pre = 0;
	    while (!q.empty()) {
	        i = q.top();
	        q.pop();
	        if ((pre ^ i) != 0 && (pre ^ i) < pre && (pre ^ i) < i) {
	            q.push(pre ^ i);
	        } else {
	            if ((ans ^ i) > ans) {
	                ans ^= i;
	            }
	            pre = i;
	        }
	    }
	    printf("%I64d\n", ans);
	}
}