#include <iostream>
#include <stdio.h>
using namespace std;
long long a[200011];
int b[5],c[5];
int i,j,k,l,m,n,p,q,x,y,z,c1,c2,c3,c4;
long long ans,tmp;
inline long long aa(int x)
{
if (x>=0) {return ((long long)(a[x]));}
if (x<0) return ((long long)(0));
}
int main()
{
scanf("%d%d%d%d%d",&c1,&c2,&c3,&c4,&n);
b[1]=c1; b[2]=c2; b[3]=c3; b[4]=c4;
a[0]=1LL;
for (i=1; i<=4; i++) for (j=1; j<=100001; j++) if (j-c[i]>=0) a[j]+=a[j-b[i]];
for (z=1; z<=n; z++)
{
for (i=1; i<=4; i++) scanf("%d",&c[i]);
scanf("%d",&m);
ans=aa(m);
for (i=1; i<=4; i++) {cout<<aa(m-(c[i]+1)*b[i])<<endl; ans-=aa(m-(c[i]+1)*b[i]);}
for (i=1; i<=3; i++) for (j=i+1; j<=4; j++) ans+=aa(m-(c[i]+1)*b[i]-(c[j]+1)*b[j]);
for (i=1; i<=2; i++) for (j=i+1; j<=3; j++) for (k=j+1; k<=4; k++) ans-=aa(m-(c[i]+1)*b[i]-(c[j]+1)*b[j]-(c[k]+1)*b[k]);
ans+=aa(m-(c[1]+1)*b[1]-(c[2]+1)*b[2]-(c[3]+1)*b[3]-(c[4]+1)*b[4]);
cout<<ans<<endl;
}
system("pause");
return 0;
}
a[x]有值,aa函数返回值0(longlong)