Skip to content

Instantly share code, notes, and snippets.

@tarik02
Last active February 20, 2019 19:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tarik02/f533700f25518bb71d8bf6b291bdbdbb to your computer and use it in GitHub Desktop.
Save tarik02/f533700f25518bb71d8bf6b291bdbdbb to your computer and use it in GitHub Desktop.
//-------------------------------BEGIN CONFIG-------------------------------//
//#ifdef LOCAL
#define IO_FILES
//#else
//#define IO_STD
//#endif
//#define IO_INPUT_NAME "input.txt"
//#define IO_OUTPUT_NAME "output.txt"
//#define IO_STD
//#define MOD 12345LL
//-------------------------------END CONFIG-------------------------------//
//-------------------------------BEGIN TEMPLATE-------------------------------//
#include <bits/stdc++.h>
using namespace std;
using ull = unsigned long long;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vu = vector<ull>;
using mii = map<int, int>;
using mll = map<ll, ll>;
using muu = map<ull, ull>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using puu = pair<ull, ull>;
using vii = vector<pii>;
using vll = vector<pll>;
using vuu = vector<puu>;
#if defined(IO_FILES)
# ifdef IO_INPUT_NAME
ifstream in(IO_INPUT_NAME);
# else
ifstream in("input.txt");
# endif
# ifdef IO_OUTPUT_NAME
ofstream out(IO_OUTPUT_NAME);
# else
ofstream out("output.txt");
# endif
#elif defined(IO_STD)
#define in cin
#define out cout
#else
#error "No input specified"
#endif
void pmain();
int main() {
#ifdef IO_STD
cin.tie(NULL); cout.tie(NULL); ios_base::sync_with_stdio(false);
#endif
pmain();
return 0;
}
template<class T> T lcm(T a, T b) {
return a / __gcd(a, b) * b;
}
template<class B, class E> B binpow(B base, E exp) {
if (exp == 0) return (B) 1;
if (exp == 1) return base;
if (exp % 2 == 0) {
B root = binpow<B, E>(base, exp / 2);
return root * root;
}
return binpow<B, E>(base, exp - 1) * base;
}
template<class M, M mod, class B, class E> B binpowmod(B base, E exp) {
if (exp == 0) return (B) 1;
if (exp == 1) return base;
if (exp % 2 == 0) {
B root = binpowmod<M, mod, B, E>(base, exp / 2);
return (root * root) % mod;
}
return (binpowmod<M, mod, B, E>(base, exp - 1) * base) % mod;
}
#ifdef MOD
template<class B, class E> B binpowmod(B base, E exp) {
return binpowmod<decltype(MOD), MOD, B, E>(base, exp);
}
#endif
template<class N> N arithsum(N a, N d, N n) {
return (2 * a + (n - 1) * d) * n / 2;
}
template<class T> void factors(T n, vector<T> &m) {
T k = n;
while (k % 2 == 0) {
m.push_back(2);
k /= 2;
}
for (T i = 3; i * i <= n; i += 2) {
if (k % i == 0) {
m.push_back(i);
k /= i;
--i;
}
}
if (k != 0) {
m.push_back(k);
}
}
template<class T> void factors(T n, map<T, T> &m) {
T k = n;
while (k % 2 == 0) {
++m[2];
k /= 2;
}
for (T i = 3; i * i <= n; i += 2) {
if (k % i == 0) {
++m[i];
k /= i;
--i;
}
}
if (k != 0) {
++m[k];
}
}
template<class T> T count_divisors(const map<T, T> &v) {
T a = 1;
for (const auto &i : v) {
a *= 1 + i.second;
}
return a;
}
//-------------------------------END TEMPLATE-------------------------------//
//-------------------------------BEGIN CODE-------------------------------//
void pmain() {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment