Skip to content

Instantly share code, notes, and snippets.

@hjroh0315
hjroh0315 / polyfft.cpp
Created April 6, 2022 13:41
FFT를 위한 Poly 클래스 (재귀) || Polynomial class for FFT (recursive)
#include<iostream>
#include<complex>
#include<vector>
#include<cmath>
#include<initializer_list>
using namespace std;
#define FLAG_DOROUND 1
const double Pi=acos(-1);
@hjroh0315
hjroh0315 / random_hasher.cpp
Last active March 25, 2022 01:29
랜덤 시드를 활용한 해시 + 해시맵
#include<bits/stdc++.h>
using namespace std;
struct SingletonRand
{
size_t value;
SingletonRand()
{
auto curTime = chrono::system_clock::now(); auto duration = curTime.time_since_epoch();
auto timer = chrono::duration_cast<chrono::nanoseconds>(duration).count();
@hjroh0315
hjroh0315 / enumerate.cpp
Created March 6, 2022 04:17
C++ enumerate (끔찍한 흑마술입니다)
#include<iostream>
#include<set>
#include<utility>
#include<cstdlib>
#include<ctime>
using namespace std;
template<class T>
struct enum_iter
{
@hjroh0315
hjroh0315 / dcpowtmp.cpp
Created February 5, 2022 03:36
분할정복 거듭제곱을 TMP로 구현해 보았습니다. I made divide-and-conquer exponentiation with TMP
#include<iostream>
#include<type_traits>
using namespace std;
using ll=long long;
template<ll val>
struct value{
ll value=val;
};
template <ll val,ll cur,ll rem>
struct dcpow{};
@hjroh0315
hjroh0315 / 2ptrdeque.cpp
Last active January 27, 2022 14:36
투포인터(?) 덱 구현
#include<iostream>
using namespace std;
template<class T>
struct ptrDeque
{
using iterator=T*;
iterator l,r;
ptrDeque():l(new T),r(l){}
void push_back(T a){*r=a;r++;}
@hjroh0315
hjroh0315 / combifnd.cpp
Created January 26, 2022 10:21
이거 맞나????????
#include<iostream>
#include<vector>
using namespace std;
using ll=long long;
const ll mod=10007;
ll mod_pow(int a,int n,int p)
{
ll ret=1;
@hjroh0315
hjroh0315 / chainedcomp.cpp
Created January 24, 2022 23:48
Chained Comparison인데, C++입니다
#include<iostream>
using namespace std;
template <class T>
struct cmp
{
T val; bool truthy;
cmp(T x): val(x), truthy(true){}
cmp(T x, bool b): val(x), truthy(b){}
cmp<T> operator<=(T v)
@hjroh0315
hjroh0315 / valarraymatrix.cpp
Created January 23, 2022 11:17
엉엉 우리 Matrix 구조체가 일하고 있어요 너무 자랑스럽네요
#include<iostream>
#include<valarray>
using namespace std;
template<class T>
struct Matrix
{
valarray<T> data;
int dim,s;
Matrix(int R, int C):data(R*C),dim(C),s(R){}
@hjroh0315
hjroh0315 / compiletimefibo.cpp
Created January 21, 2022 15:19
정신나간 컴파일타임 피보나치
#include<iostream>
template <int ... Ns> struct sequence {};
template <int ... Ns> struct seq_gen;
template <int I,int J, int ... Ns>
struct seq_gen<I,J, Ns...>
{
using type = typename seq_gen<
J-I,I,J, Ns...>::type;
@hjroh0315
hjroh0315 / cyclicshift_with_variable_width. cpp
Created January 12, 2022 12:28
rotr, rotl에 대한 크기를 런타임에 지정 가능한 구현
#include <iostream>
#include <bitset>
using namespace std;
template<class T>
T rotrN(T in, int N, int s);
template<class T>
T rotlN(T in, int N, int s);