Pagini recente » Cod sursa (job #131332) | Cod sursa (job #1938193) | Cod sursa (job #3134158) | Cod sursa (job #2651398) | Cod sursa (job #1594432)
#include <cstdio>
#define maxx(a,b) (a>b? a:b)
#define minn(a,b) (a<b? a:b)
using namespace std;
long long a,b,c,x,y,z,s;
long long max1,max2,min1,min2;
long long sol,aux;
int i;
int main()
{
freopen("plus.in","r",stdin);
freopen("plus.out","w",stdout);
scanf("%lld",&s);
scanf("%lld %lld",&a,&x);
scanf("%lld %lld",&b,&y);
scanf("%lld %lld",&c,&z);
max1=maxx(0,b*y);
max2=maxx(0,c*z);
min1=minn(0,b*y);
min2=minn(0,c*z);
for(i=0;i<=a;i++,s-=x)
{
if(!y)
{
if(!z) {if(s==0) sol+=(b+1)*(c+1);}
else {aux=s/z; if(aux>=0 &&aux<=c) sol+=b+1;}
}
else
{
if(!z) {aux=s/y; if(aux>=0 && aux<=b) sol+=c+1;}
else sol+=maxx(0,minn(s-min1,max2)-maxx(s-max1,min2)+1);
}
}
printf("%lld",sol);
return 0;
}