Skip to content

Instantly share code, notes, and snippets.

struct frac{
using ll = long long;
ll fz, fm;
frac() = default;
frac(ll fz, ll fm) { // 构造函数变量名最好不要跟类成员名一样!
assert(fm != 0);
if (fm < 0) fm *= -1, fz *= -1;
ll g = __gcd(abs(fz), fm);
fz /= g, fm /= g;
@GoBigorGoHome
GoBigorGoHome / geometry.cpp
Last active December 16, 2018 13:30
计算几何模板(建设中)
template <typename T>
T sq(const T &a){return a * a;}
using ldb = long double;
struct pnt{
ldb x, y;
ldb len()const{
return std::sqrt(x * x + y * y);
}
ldb len2()const{
@GoBigorGoHome
GoBigorGoHome / dinic.cpp
Last active February 20, 2019 02:39
Dinic 模板
#define SZ(x) (int)(x).size()
const int N = 2e3+5;
struct arc{ //据说数据量大时,vector存图比前向星块
int v;
ll residual_capacity;
int next;
};
@GoBigorGoHome
GoBigorGoHome / KD-Tree template.cpp
Created November 28, 2018 01:24
KD Tree 模板
template <int DIM, int N = 100000>
class KDtree {
#define lson id<<1
#define rson id<<1|1
#define sqr(x) ((x)*(x))
// kd-tree
using coord = array<int,DIM>;
constexpr static auto dist2 = [](const coord &a, const coord &b) {
ll ans = 0;
for (int i = 0; i < DIM; i++) {
@baiwfg2
baiwfg2 / CMakeLists.txt
Created September 29, 2018 12:42
How to use add_custom_target and add_custom_command correctly in cmake
# References:
# https://cmake.org/cmake/help/latest/command/add_custom_target.html
# https://samthursfield.wordpress.com/2015/11/21/cmake-dependencies-between-targets-and-files-and-custom-commands/
# https://gist.github.com/socantre/7ee63133a0a3a08f3990
# https://stackoverflow.com/questions/24163778/how-to-add-custom-target-that-depends-on-make-install
# https://stackoverflow.com/questions/30719275/add-custom-command-is-not-generating-a-target
# https://stackoverflow.com/questions/26024235/how-to-call-a-cmake-function-from-add-custom-target-command
# https://blog.csdn.net/gubenpeiyuan/article/details/51096777
cmake_minimum_required(VERSION 3.10)
@GoBigorGoHome
GoBigorGoHome / 【模板】树的点分治.cpp
Last active November 8, 2019 14:17
CodeChef July 18 SUBWAY
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x <<": " << (x) << endl
#define DEBUG printf("Passing [%s] in LINE %d\n",__FUNCTION__,__LINE__)
#ifdef LOCAL
#define see(x) cout << #x << ": " << (x) << endl
@pps83
pps83 / ctz_clz.cpp
Last active June 19, 2025 12:59
__builtin_ctz (ctzl, ctzll) and __builtin_clz (clzl, clzll) for Visual Studio
// Note, bsf/bsr are used by default.
// Enable /arch:AVX2 compilation for better optimizations
#if defined(_MSC_VER) && !defined(__clang__)
#include <intrin.h>
#include <limits.h>
#if (defined(__cplusplus) && (__cplusplus >= 202002L)) || \
(defined(_MSVC_LANG) && (_MSVC_LANG >= 202002L))
#include <type_traits>
@oliveratgithub
oliveratgithub / emojis.json
Last active February 28, 2026 08:52
Emoji-list with emojis, names, shortcodes, unicode and html entities [massive list]
{
"emojis": [
{"emoji": "👩‍👩‍👧‍👧", "name": "family: woman, woman, girl, girl", "shortname": ":woman_woman_girl_girl:", "unicode": "1F469 200D 1F469 200D 1F467 200D 1F467", "html": "&#128105;&zwj;&#128105;&zwj;&#128103;&zwj;&#128103;", "category": "People & Body (family)", "order": ""},
{"emoji": "👩‍👩‍👧‍👦", "name": "family: woman, woman, girl, boy", "shortname": ":woman_woman_girl_boy:", "unicode": "1F469 200D 1F469 200D 1F467 200D 1F466", "html": "&#128105;&zwj;&#128105;&zwj;&#128103;&zwj;&#128102;", "category": "People & Body (family)", "order": ""},
{"emoji": "👩‍👩‍👦‍👦", "name": "family: woman, woman, boy, boy", "shortname": ":woman_woman_boy_boy:", "unicode": "1F469 200D 1F469 200D 1F466 200D 1F466", "html": "&#128105;&zwj;&#128105;&zwj;&#128102;&zwj;&#128102;", "category": "People & Body (family)", "order": ""},
{"emoji": "👨‍👩‍👧‍👧", "name": "family: man, woman, girl, girl", "shortname": ":man_woman_girl_girl:", "unicode": "1F468 200D 1F469 200D 1F467 200D 1F467", "html": "&#128104;&zwj;&#128105;&z
@dmurawsky
dmurawsky / index.js
Last active April 22, 2025 13:06
How to make a page full height in Next.js
const FullHeightPage = () => (
<div>
Hello World!
<style global jsx>{`
html,
body,
body > div:first-child,
div#__next,
div#__next > div {
height: 100%;
@Geoyi
Geoyi / install virtualenv ubuntu 16.04.md
Created September 16, 2017 12:19 — forked from rezafarhadur/install virtualenv ubuntu 16.04.md
How to install virtual environment on ubuntu 16.04

How to install virtualenv:

Install pip first

sudo apt-get install python3-pip

Then install virtualenv using pip3

sudo pip3 install virtualenv