A Simple EquationProblem code: EQUATION |
All submissions for this problem are available.
Statement
Given N,A,B,C, find how many solutions exist to the equation : a + b + c ≤ N, such that 0 ≤ a ≤ A, 0 ≤ b ≤ B, 0 ≤ c ≤ C.
Input
The first line contains the number of test cases T (1<= T <= 50). Each test case contains 4 integers, N,A,B,C. 0 ≤ N,A,B,C ≤ 2500
Output
Output T lines, one for each test case.
Sample Input
2 4 3 2 1 1 1 1 1
Sample Output
20 4
| Date: | 2010-09-10 |
| Time limit: | 1s |
| Source limit: | 50000 |
| Languages: | C C99 strict C++ 4.0.0-8 C++ 4.3.2 PAS gpc PAS fpc JAVA NICE JAR C#2 NEM ST ASM D FORT ADA BASH PERL PYTH RUBY LUA ICON PIKE PHP SCM guile SCM qobi LISP sbcl LISP clisp SCALA HASK ERL CAML CLPS PRLG WSPC BF ICK JS |
Comments

Fetching successful submissions

a solution means a,b,c have
a solution means a,b,c have to be integers right??
a solution means a,b,c have
a solution means a,b,c have to be integers right??
input is given with a space
input is given with a space between the numbers or as a string?
@Vijay: That is correct.
@Vijay: That is correct.
@Amit: A space between
@Amit: A space between numbers
how to submit the code
how to submit the code
@Rakesh: Have you browsed
@Rakesh: Have you browsed through the FAQ ?
i m getting restricted
i m getting restricted content,why i cant submit
@harsha:no i didnt find any
@harsha:no i didnt find any thing in FAQ
@anant: you need to login
@anant: you need to login with team id to submit. You cannot submit with you individual userid.
how to submit???? n how to
how to submit???? n how to get the team id???
is it neccessary tht a,b,c
is it neccessary tht a,b,c should be intrger??
@Rakesh @Ankit: Registration
@Rakesh @Ankit: Registration is now over. You needed to regiter for a team before the contest to submit a solution. The rules are mentioned here
@Firebird: yes.
@Firebird: yes.
hey can any tell me how to
hey can any tell me how to submit...........?
I am unable to
I am unable to submit.restricted content!! plese check..
@nikhil: you need to login
@nikhil: you need to login with your team id that you must have registered for this contest. Let us know if you doing this and still unable to submit.
Hi ! Can anyone explain the
Hi !
Can anyone explain the solutions of the team "star_teamname" ?
How does the formula works ?
even O(n^2) giving tle......
even O(n^2) giving tle......
can any body please explain
can any body please explain the formulae
/*This will work
/*This will work */
#include<stdio.h>
int main(void)
{
int n,a,b,c,A,B,C,m,count;
scanf("%d",&n);
while(n-- > 0)
{
scanf("%d %d %d %d",&m,&A,&B,&C);
count=0;
for(a=0;a<=A;a++)
for(b=0;b<=B;b++)
for(c=0;c<=C;c++)
{
if(a+b+c <= m)
count++;
}
printf("%dn",count);
}
return 0;
}
I have the best solution of
I have the best solution of this problem, which is the easiest solution till available.
this will not work ...Time
this will not work ...Time limit exceedign will come