本质上\(c[]\)其实是对于每一位做的一个前缀和(高维前缀和)
而\(b[]\)是原数组
每一位的长度是\(a[]\)
对于\(a[i] > 1\)的位
可以知道是不超过\(log_2m\)的
单独考虑每一位
暴力还原
wzz大佬代码400b- momomo
#include<bits/stdc++.h>
#define int long long
#define fo(i, n) for(int i = 1; i <= (n); i ++)
#define out(x) cerr << #x << " = " << x << "\n"
#define type(x) __typeof((x).begin())
#define foreach(it, x) for(type(x) it = (x).begin(); it != (x).end(); ++ it)
using namespace std;
// by piano
template<typename tp> inline void read(tp &x) {
x = 0; char c = getchar(); bool f = 0;
for(; c < '0' || c > '9'; f |= (c == '-'), c = getchar());
for(; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
if(f) x = -x;
}
template<typename tp> inline void arr(tp *a, int n) {
for(int i = 0; i < n; i ++)
cout << a[i] << " ";
puts("");
}
const int N = 1e6 + 233;
int n, a[N], c[N], m;
main(void) {
read(n);
for(int i = 0; i < n; i ++)
read(a[i]);
read(m); a[n] = m;
for(int i = 0; i < m; i ++)
read(c[i]);
int all = 1;
for(int i = 0; i <= n; i ++)
if(a[i] > 1) {
for(int j = m - 1; j >= 0; j --)
if((j / all) % a[i])
c[j] -= c[j - all];
if((all *= a[i]) > m) break;
}
cout << n << "\n";
arr(a, n);
cout << m << "\n";
arr(c, m);
}