[Codeforces 903 D. Almost Difference]树状数组+大数模板
分类:FenwickTree
BigInteger
template
1. 题目链接
[Codeforces 903 D. Almost Difference]
2. 题意描述
3. 解题思路
思路很简单,首先,对每个数进行离散化。树状数组维护每个数出现的次数,以及区间和。
但是,这题最终的答案会达到 1019 以上, 64bit 的 long long 存不下来。
然后,从cf上扒下了一个比较完美的大数模板。=_=!
cf竟然不支持__int128
4. 实现代码
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double lb;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ull, ull> puu;
typedef pair<lb, lb> pbb;
const int inf = 0x3f3f3f3f;
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
template<typename T> inline void umax(T &a, T b) { a = max(a, b); }
template<typename T> inline void umin(T &a, T b) { a = min(a, b); }
template<typename T> inline T randIntv(const T& a, const T& b) { return (T)rand() % (b - a + 1) + a; }
void debug() { cout << endl; }
template<typename T, typename ...R> void debug (T f, R ...r) { cout << "[" << f << "]"; debug (r...); }
const int base = 1000000000;
const int base_digits = 9;
struct bigint {
vector<int> z;
int sign;
bigint() : sign(1) { }
bigint(long long v) { *