Skip to content

Instantly share code, notes, and snippets.

time-river time-river

Block or report user

Report or block time-river

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@time-river
time-river / permutations.py
Last active May 7, 2019
consideration of permutations.
View permutations.py
'''
link
- https://leetcode.com/problems/permutations/
problem:
Given a collection of distinct integers, return all possible permutations.
Example:
Input: [1,2,3]
Output:
[
@time-river
time-river / multiple_pack-2.cpp
Created Jul 31, 2018
背包九讲之多重背包 一维数组
View multiple_pack-2.cpp
/*
* 背包九讲之多重背包 一维数组
* from: http://acm.hdu.edu.cn/showproblem.php?pid=2191
* reference: https://blog.csdn.net/hellobabygogo3/article/details/7993547
*/
#include <bits/stdc++.h>
using namespace std;
@time-river
time-river / multiple_pack-1.cpp
Created Jul 31, 2018
背包九讲之多重背包,二维数组
View multiple_pack-1.cpp
/*
* 背包九讲之多重背包 二维数组
* from: http://acm.hdu.edu.cn/showproblem.php?pid=2191
* reference: https://blog.csdn.net/hellobabygogo3/article/details/7993547
*/
#include <bits/stdc++.h>
using namespace std;
@time-river
time-river / complete_pack-2.cpp
Created Jul 31, 2018
背包九讲之完全背包,恰好装满,一维(滚动)数组
View complete_pack-2.cpp
/*
* 背包九讲之完全背包 恰好装满 滚动数组
* from: http://acm.hdu.edu.cn/showproblem.php?pid=1114
* reference: https://blog.csdn.net/liujc_/article/details/44003167
*/
#include <bits/stdc++.h>
#define PMAX 1000000001
@time-river
time-river / complete_pack-1.cpp
Created Jul 31, 2018
背包九讲之完全背包,恰好装满,二维数组
View complete_pack-1.cpp
/*
* 背包九讲之完全背包 恰好装满 二维数组
* from: http://acm.hdu.edu.cn/showproblem.php?pid=1114
* reference: https://blog.csdn.net/liujc_/article/details/44003167
*/
#include <bits/stdc++.h>
#define NMAX 500
#define PMAX 1000000001
@time-river
time-river / one_zero_pack-2.cpp
Last active Jul 31, 2018
背包九讲之01背包,一维(滚动)数组解法
View one_zero_pack-2.cpp
/*
* 背包九讲之01背包 滚动数组
* from: http://www.hawstein.com/posts/dp-knapsack.html
*/
#include <bits/stdc++.h>
using namespace std;
#define MAXN 1000
@time-river
time-river / one_zero_pack-1.cpp
Last active Jul 31, 2018
背包九讲之01背包,二维数组解法,打印选择的背包
View one_zero_pack-1.cpp
/*
* 背包九讲之01背包 二维数组
* from: http://www.hawstein.com/posts/dp-knapsack.html
*/
#include <bits/stdc++.h>
using namespace std;
#define MAXN 1000
@time-river
time-river / ip-datagram.py
Last active Jun 6, 2018
like '[simple-tun-read-write.py](https://gist.github.com/time-river/f2288ae1dbe8bfa5cc84a841c9a507ad)', but automatic configure tun device and route table.
View ip-datagram.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
'''
description:
like 'simple-tun-read-write.py', but automatic configure tun device and route table.
catch all ip packet and print
'IP protocol version + IP header size'
'protocol of encapsulated packet'
'source IP'
@time-river
time-river / simple-tun-read-write.py
Last active Jun 6, 2018
a simple program which could print all package of content sended from local machine
View simple-tun-read-write.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
'''
a simple program which could print all package of content sended from local machine
prepare:
# ip tuntap add mode tun tun0
# ip link set tun0 up
# ip addr add 10.0.0.2/24 dev tun0
# ip route add default via 10.0.0.2 dev tun0 table 100
You can’t perform that action at this time.