线性预处理逆元
for (int i = 1 ; i <= n ; i++) inv[i] = (mod - mod / i) * inv[mod % i] % mod;
大质数
NTT模数&原根表
1e14 : 360023843327831
快速乘:
ll mul(ll a,ll b){
return ((a*b-(long long)(a / (long double)mod * b + 1e-3)*mod+mod)%mod);
}
偶尔可以用的卡常黑科技(好像codeforces上被封了?有一次反而变慢了)
bzoj会CE,只能手动O3
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("avx")
cin关闭同步
std::ios::sync_with_stdio(false);
重载小于号
http://c.biancheng.net/view/520.html
// Compares keys that are unique_ptr<string> objects
class Key_compare
{
public:
bool operator () (const std::unique_ptr<string>& p1, const std::unique_ptr <string>& p2) const
{
return *p1 < *p2;
}
};
或者在struct中重载
bool operator>(const Name& name) const
{
return second > name.second ||(second == name.second && first > name.first);
}
std::map<Name,size_t, std::greater<Name>>people
bitset
bitset遍历所有的1
实测复杂度是O(max(count,n / w)) , 在1很少时很快。1满时比直接for慢4倍
1e9 本机 4s(codeforces 8s)(不含输出)
for(int i=BS._Find_first();i< BS.size();i = BS._Find_next(i))
cout<<i<<endl;
运算符优先级
https://blog.youkuaiyun.com/wu_tongtong/article/details/78176175