## 10014 - Simple calculations

All about problems in Volume 100. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

tan_Yui
Experienced poster
Posts: 155
Joined: Sat Jul 10, 2004 12:41 am

### Re: 10014 Run Time Error

Your recursive function cannot work if n>1.
Then the function continues infinitely, so the judge said RE.

Best regards.

Staryin
New poster
Posts: 12
Joined: Fri Dec 16, 2005 4:22 pm
Location: shanghai/china
Contact:

### 10014 WA WHO CAN GIVE ME TESTDATA!!!

10014 WA WHO CAN GIVE ME TESTDATA!!!

tmdrbs6584
Learning poster
Posts: 98
Joined: Sat Jan 21, 2006 12:45 pm
Location: Busan,Corea(Republic of)

### Hmm

Why don't you make bigger array size?

taskin
New poster
Posts: 22
Joined: Sun Jan 01, 2006 1:43 pm
Location: Bangladesh
thanks. yes, this program falls in an infinite recursion when n > 1. in fact, it's not possible to solve this by using recursive call.

dust_cover
New poster
Posts: 23
Joined: Tue Sep 12, 2006 9:46 pm

### 10014--output of the judge's data!!!!!!!

hi Revenger,

I was trying to solve the problem. But getting WA.

CAn u please tell me the output of the judges's data so I can match it with my one!

--thnx in advance
i wanna give it a try....

dust_cover
New poster
Posts: 23
Joined: Tue Sep 12, 2006 9:46 pm

### 10014

Hello,
I got ACC. I made wrong calculation!
Thanx in advance!
i wanna give it a try....

rana_cse_ruet
New poster
Posts: 7
Joined: Mon Mar 05, 2007 9:59 am

### 10014

t
Last edited by rana_cse_ruet on Thu Mar 15, 2007 5:46 pm, edited 1 time in total.

Debashis Maitra
Learning poster
Posts: 62
Joined: Sun Jul 09, 2006 8:31 am
Location: University of Dhaka
Contact:
try to read carefully the output format of the problem
Print a blank line between the outputs for two consecutive test cases.
I hope it will help you

And remember dont open a new thread if there is one already. you can find old posts using search and use them to post

Best of luck
Akash chhoyar swopno
Dream to touch the sky

rana_cse_ruet
New poster
Posts: 7
Joined: Mon Mar 05, 2007 9:59 am
Thanks, but i thought a have already printed that after each output. Is there any other way to print a blank line? Please help me about the new line if can...

Debashis Maitra
Learning poster
Posts: 62
Joined: Sun Jul 09, 2006 8:31 am
Location: University of Dhaka
Contact:
Your question is not clear...

If your question is how can you print a blank line between 2 test case

Answer is

Code: Select all

.......
main()
{
....
....
char btwn_case=0;
...........
while(tast_case--)
{
...
....
......
if (btwn_case)printf("\n");/*print it before printing any output*/
else btwn_case=1;

/*Now print your output of this test case*/
....
.....
.....
}
}

This code prints new line between 2 test cases because
it prints a new line before the output (except first case)

I hope it will help you

Best of luck
Last edited by Debashis Maitra on Sat Mar 10, 2007 4:12 pm, edited 1 time in total.
Akash chhoyar swopno
Dream to touch the sky

Debashis Maitra
Learning poster
Posts: 62
Joined: Sun Jul 09, 2006 8:31 am
Location: University of Dhaka
Contact:
Rana

Now Remove your code
Akash chhoyar swopno
Dream to touch the sky

rana_cse_ruet
New poster
Posts: 7
Joined: Mon Mar 05, 2007 9:59 am
Thanks a lot. I got the point.

Debashis Maitra
Learning poster
Posts: 62
Joined: Sun Jul 09, 2006 8:31 am
Location: University of Dhaka
Contact:
Thats good
Now remove your code
Akash chhoyar swopno
Dream to touch the sky

linux
Learning poster
Posts: 56
Joined: Sat Jul 01, 2006 12:21 pm
Location: CA-95054
Contact:

### simple calculations 10014

I'm got wrong answer. I need sample outputs for inputs. Please help.
Solving for fun..

aeiou
New poster
Posts: 21
Joined: Wed May 07, 2008 11:32 am

### 10014 - Simple Calculations

Hi,

I ve been trying this problem for a long time...but getting WA..
I m sure about my calculations....
I used the formula : (n+1)a1=n*a0 + (an+1) - 2(n*c1 + (n-1)*c2 + (n-2)*c3 + ... + 1*cn)

Here's my code :

Code: Select all

#include<iostream>
#include<cmath>
#include<vector>
using namespace std;

int main ()
{
int t;
while ( scanf ( "%d" , &t ) == 1 )
{
while ( t -- )
{
int n , m;
double a0 , an;
scanf ( "%d %lf %lf" , &n , &a0 , &an );
vector <double> ci(n);
for ( int i = 0 ; i < n ; i ++ )
scanf ( "%lf" , &ci[i]);
m = n;
a0 = ( n * a0 );
a0 += an;
double x = 0.0;
for ( int i = 0 ; i < n ; i ++ )
{
x += ( n * ci[i] );
n --;
}
x *= 2;
double ans = ( a0 - x ) / ( m + 1.0 );
printf ( "%.2lf\n" , ans);
if ( t > 0 )
cout << endl;
}
}
return 0;
}
Can anybody help me out of this ????!!!!!!!!

for ( ; ; )
{
cout << "Thankx in advance";
}