Cod sursa(job #117237)

Utilizator DastasIonescu Vlad Dastas Data 20 decembrie 2007 23:22:07
Problema Bilute Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.97 kb
#include <cstdio>

FILE *in = fopen("plus.in","r"), *out = fopen("plus.out","w");

int s;
int a, b,
    c, d,
    e, f;

long long sol;

int main()
{
    fscanf(in, "%d %d %d %d %d %d %d", &s, &a,&b,&c,&d,&e,&f);
    //printf("%d %d\n%d %d\n%d %d\n", a, b, c, d, e, f);

    for ( int i = 0; i <= a; ++i )
        for ( int j = 0; j <= c; ++j )
        {
            int t = i*b + j*d;

            if ( f == -1 )
            {
                if ( e*f + t <= s && t >= s )
                    ++sol;
            }
            else if ( f == 0 )
            {
                if ( e*f == s )
                    sol = sol + e + 1;
            }
//            else
//            {
//                if ( e*f + t >= s )
//                    ++sol;
//            }
        }

    fprintf(out, "%lld\n", sol);

	return 0;
}

/*
           for ( int k = 0; k <= e; ++k )
                if ( i*b + j*d + k*f == s )
                    ++sol;
*/