题目
代码
#include <bits/stdc++.h>
using namespace std;
const int N = 21;
int c[N];
int a[N];
int b[N];
void init(int n)
{
c[0] = 1;
for(int i = 1; i <= n; i++)
{
c[i] = c[i-1] * a[i];
}
}
int main()
{
int n, m;
cin >> n >> m;
for(int i = 1; i <= n; i++) cin >> a[i];
init(n);
int last = 0;
for(int i = 1; i <= n; i++)
{
int remain = m % c[i];
b[i] = (remain - last) / c[i-1];
last = remain;
}
for(int i = 1; i <= n; i++)
{
cout << b[i] << " ";
}
return 0;
}