This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
""" | |
ip_complement.py – 计算一组 IPv4 / IPv6 CIDR 的互补网段 | |
用法示例: | |
# 直接在命令行给出网段 | |
python ip_complement.py 10.0.0.0/8 192.168.0.0/16 2001:db8::/32 | |
# 从文件或管道读取,再输出 JSON | |
cat cidr.txt | python ip_complement.py -j |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdio> | |
#include <algorithm> | |
using namespace std; | |
typedef long long ll; | |
const ll mod = 65521; | |
inline ll pow(ll a, ll b) { | |
ll ret = 1; |