缺省源
自用,你不见得会用。
快读:
点击查看代码
#define getc() getchar_unlocked()
#define putc(a) putchar_unlocked(a)
#define en_ putc('\n')
#define e_ putc(' ')
template<class T> inline T in() {
T n = 0; char p = getc();
while (p < '-') p = getc();
bool f = p == '-' ? p = getc() : 0;
do n = n * 10 + (p ^ 48), p = getc();
while (isdigit(p));
return f ? -n : n;
}
template<class T> inline T in(T &a) { return a = in<T>(); }
template<class T, class ... Args> inline void in(T &t, Args&... args) { in(t), in(args...); }
template<class T> inline void out(T n) {
if(n < 0) putc('-'), n = -n;
if(n > 9) out(n / 10);
putc(n % 10 + '0');
}
不取模
点击查看代码
// code by 樓影沫瞬_Hz17
#include <bits/stdc++.h>
using namespace std;
#define getc() getchar_unlocked()
#define putc(a) putchar_unlocked(a)
#define en_ putc('\n')
#define e_ putc(' ')
#define int long long
using pii = pair<int, int>;
template<class T> inline T in() {
T n = 0; char p = getc();
while (p < '-') p = getc();
bool f = p == '-' ? p = getc() : 0;
do n = n * 10 + (p ^ 48), p = getc();
while (isdigit(p));
return f ? -n : n;
}
template<class T> inline T in(T &a) { return a = in<T>(); }
template<class T, class ... Args> inline void in(T &t, Args&... args) { in(t), in(args...); }
template<class T> inline void out(T n) {
if(n < 0) putc('-'), n = -n;
if(n > 9) out(n / 10);
putc(n % 10 + '0');
}
template<class T1, class T2> T1 max(T1 a, T2 b) { return a > b ? a : a = b;}
template<class T1, class T2> T1 min(T1 a, T2 b) { return a < b ? a : a = b;}
constexpr int N = 2e5 + 10;
signed main() {
#ifndef ONLINE_JUDGE
freopen("i", "r", stdin);
freopen("o", "w", stdout);
#endif
}
// 星間~ 干渉~ 融解~ 輪迴~ 邂逅~ 再生~ ララバイ~
取模:
点击查看代码
// code by 樓影沫瞬_Hz17
#include <bits/stdc++.h>
using namespace std;
#define getc() getchar_unlocked()
#define putc(a) putchar_unlocked(a)
#define en_ putc('\n')
#define e_ putc(' ')
template <int MOD> struct modint {
int val;
static int norm(const int& x) { return x < 0 ? x + MOD : x; }
static constexpr int get_mod() { return MOD; }
modint inv() const {
assert(val);
int a = val, b = MOD, u = 1, v = 0, t;
while (b > 0) t = a / b, swap(a -= t * b, b), swap(u -= t * v, v);
assert(!b);
return modint(u);
}
modint() {}
modint(const int& m) : val(norm(m % MOD)) {}
modint(const long long& m) : val(norm(m % MOD)) {}
template<typename T> modint(const T m) : val(norm((long long)m % MOD)) {}
// template<class T> operator T() const { return val; }
modint operator-() const { return modint(norm(-val)); }
modint operator!() const { return !val; }
modint operator~() const { return norm(~val); }
modint &operator++() { return (++ this->val) >= MOD ? (this->val -= MOD), *this : *this; }
modint &operator--() { return (-- this->val) < 0 ? (this->val += MOD), *this : *this; }
modint operator++(int) { return norm((++ *this).val - 1); }
modint operator--(int) { return norm((-- *this).val + 1); }
bool operator!=(const modint& o) { return val != o.val; }
bool operator==(const modint& o) { return val == o.val; }
bool operator<(const modint& o) { return val < o.val; }
bool operator>(const modint& o) { return val > o.val; }
bool operator<=(const modint& o) { return val <= o.val; }
bool operator>=(const modint& o) { return val >= o.val; }
modint& operator+=(const modint& o) { return val = (1ll * val + o.val) % MOD, *this; }
modint& operator-=(const modint& o) { return val = norm(1ll * val - o.val), *this; }
modint& operator*=(const modint& o) { return val = static_cast<int>(1ll * val * o.val % MOD), *this; }
modint& operator/=(const modint& o) { return *this *= o.inv(); }
modint& operator%=(const modint& o) { assert(o.val); return val %= o.val, *this; }
modint& operator^=(const modint& o) { return val ^= o.val, *this; }
modint& operator>>=(const modint& o) { return val >>= o.val, *this; }
modint& operator<<=(const modint& o) { return (val <<= o.val) %= MOD, *this; }
modint operator-(const modint& o) const { return modint(*this) -= o; }
modint operator+(const modint& o) const { return modint(*this) += o; }
modint operator*(const modint& o) const { return modint(*this) *= o; }
modint operator/(const modint& o) const { return modint(*this) /= o; }
modint operator%(const modint& o) const { return modint(*this) %= o; }
modint operator^(const modint& o) const { return modint(*this) ^= o; }
modint operator>>(const modint& o) const { return modint(*this) >>= o; }
modint operator<<(const modint& o) const { return modint(*this) <<= o; }
friend std::istream& operator>>(std::istream& is, modint& a) {
long long v;
return is >> v, a.val = norm(v % MOD), is;
}
friend std::ostream& operator<<(std::ostream& os, const modint& a) { return os << a.val; }
friend std::string tostring(const modint& a) { return std::to_string(a.val); }
};
using mint = modint<1000000007>;
using pii = pair<int, int>;
template<class T> inline T in() {
T n = 0; char p = getc();
while (p < '-') p = getc();
bool f = p == '-' ? p = getc() : 0;
do n = n * 10 + (p ^ 48), p = getc();
while (isdigit(p));
return f ? -n : n;
}
template<class T> inline T in(T &a) { return a = in<T>(); }
template<class T, class ... Args> inline void in(T &t, Args&... args) { in(t), in(args...); }
template<class T> inline void out(T n) {
if(n < 0) putc('-'), n = -n;
if(n > 9) out(n / 10);
putc(n % 10 + '0');
}
template<class T1, class T2> T1 max(T1 a, T2 b) { return a > b ? a : a = b;}
template<class T1, class T2> T1 min(T1 a, T2 b) { return a < b ? a : a = b;}
const int N = 2.5e4 + 10, mod = 1000000009;
signed main() {
#ifndef ONLINE_JUDGE
freopen("i", "r", stdin);
freopen("o", "w", stdout);
#endif
}
// 星間~ 干渉~ 融解~ 輪迴~ 邂逅~ 再生~ ララバイ~