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
| Author: | anshuman_singh |
| Date Added: | 10-09-2010 |
| Time Limit: | 1 sec |
| Source Limit: | 50000 Bytes |
| Languages: | ADA, ASM, BASH, BF, C, C99 strict, CAML, CLOJ, CLPS, CPP 4.0.0-8, CPP 4.3.2, CS2, D, ERL, F#, FORT, GO, HASK, ICK, ICON, JAR, JAVA, JS, LISP clisp, LISP sbcl, LUA, NEM, NICE, PAS fpc, PAS gpc, PERL, PERL6, PHP, PIKE, PRLG, PYTH, PYTH 3.1.2, RUBY, SCALA, SCM guile, SCM qobi, ST, TEXT, WSPC |
Comments
SUCCESSFUL SUBMISSIONS FOR THIS PROBLEM:
HELP
Program should read from standard input and write to standard output. After you submit a solution you can see your results by clicking on the [My Submissions] tab on the problem page. Below are the possible results:
- Accepted
Your program ran successfully and gave a correct answer. If there is a score for the problem, this will be displayed in parenthesis next to the checkmark. - Time Limit Exceeded
Your program was compiled successfully, but it didn't stop before time limit. Try optimizing your approach. - Wrong Answer
Your program compiled and ran succesfully but the output did not match the expected output. - Runtime Error
Your code compiled and ran but encountered an error. The most common reasons are using too much memory or dividing by zero. For the specific error codes see the help section. - Compilation Error
Your code was unable to compile. When you see this icon, click on it for more information.
If you are still having problems, see a sample solution here.

Fetching successful submissions

O(n^2) is not giving TLE
O(n^2) is not giving TLE ..actually C is slow.....changed to C++ and wallah!!
and found 4.3.2 slower than 4.0.0 ... ne1 tell why
??
Sir, what if A+B+C<N
Sir,
what if A+B+C<N
i hav submitted d solution
i hav submitted d solution given below and i got TLE. What should i do??
#include<stdio.h>
int main(void)
{
int i,j,k, a,b,c,n,count=0,t;
scanf("%d",&t);
while(t!=0)
{
scanf("%d %d %d %d",&n,&a,&b,&c);
for(i=0;i<=a;i++)
for(j=0;j<=b;j++)
for(k=0;k<=c;k++)
if(i+j+k<=n)
count++;
printf("%dn",count);
t--;
count=0;
}
return 0;
}
Do you think
Do you think 50*2500*2500*2500 is going to run within one second? Nope. You'll need to start again.
@Admin: http://www.codechef
@Admin:
http://www.codechef.com/viewsolution/450377
This code seems to be perfect. Why am I getting wrong answer???
It gives the wrong answer on
It gives the wrong answer on a test case you really should have checked..
Thank you!
Thank you!
2
2
Can someone think of a case
oops soething
Could anyone plz explain the
i m getting run time error...
@admin: i always face the
@admin: Pls check
never mind .. got it
any buddy let me know the
plz any body check my code as
@admin : plz give me some
Am I the only one who sees
Saikat, the "?" are supposed
ah ty!! :)