## 10302 - Summation of Polynomials

Moderator: Board moderators

### Weird??

when i declare variable using double my compiler give the answer
1562562500624999940 which is WA

then when i changed it to long long the answer is
85550656 which is AC

actually what is the output for 50000 ??
am i missing something here??
can someone explain to me this simple question..
thanks
kurnia w
New poster

Posts: 18
Joined: Fri Dec 06, 2002 3:53 pm
Location: Indonesia

Please, if some of you got the correct answer for this "stupid" problem, can you post examples with extra-large numbers? (i.e., post inputs and outputs of as great numbers as you can)

I think i'm near the correct answer, only a rare overflow output may be the reason of my wrong answers...

Dejarik
New poster

Posts: 32
Joined: Sun Mar 07, 2004 1:23 pm
Location: Barcelona, SPAIN

### kurnia

i think u use Turbo C++
that why you got

when i declare variable using double my compiler give the answer
1562562500624999940 which is WA

then when i changed it to long long the answer is
85550656 which is AC

long long doesn't work in TC & long long count as long in TC. if you use Dev you can find the result. or in VC you can int64 as data type.

for 50000 the result may be
1562562500625000000.
osan
New poster

Posts: 47
Joined: Tue Jul 29, 2003 12:03 pm

### thanks everyone

guys i was in real problem. i was getting WA. i was using data type as long long. but i changed it into long double then got AC.

& in long double the output for 50000 is 1562562500624999900.
osan
New poster

Posts: 47
Joined: Tue Jul 29, 2003 12:03 pm

Just wanted to say a long overdue thanks.....
mido
Learning poster

Posts: 78
Joined: Sun Jun 16, 2002 9:48 pm
Location: Cairo,Egypt

### 10302 I want to learn (Polynomials)

I've solved the problem "Summation of Polynomials" recently, using the expression n * n * (n + 1) * (n + 1) /4 . This expression was calculated following the steps described in the "introduction" of the problem, I suppose. Unfortunately I can't understand those steps.

Can someone explain me how to do that? I would be grateful...
Thanks
gateKeeper
New poster

Posts: 2
Joined: Sat Jun 04, 2005 10:07 pm

### 10302 [Polynomials] getting WA?

Here is the code

Code: Select all
`     removed after AC`

use long long to get AC.
Salman
New poster

Posts: 25
Joined: Thu Jun 26, 2003 9:45 am

### 10302 - data types is long long

Hi

If u r using (n*n*(n+1)*(n+1))/4 formula then use long long data type . It works for me and I got AC.

Salman
Salman
New poster

Posts: 25
Joined: Thu Jun 26, 2003 9:45 am

### Help reqd

Am getting WA...and even my compiler gives my some problem...
can anyone tell me whats the problem..

here's my code....

<deleted after acceptence>
Last edited by Viswanathan V on Fri Feb 02, 2007 7:19 pm, edited 1 time in total.
Viswanathan V
New poster

Posts: 8
Joined: Mon Jan 22, 2007 9:08 pm

Use long long and you will get AC.
Thiago Sonego Goulart - UFMG/Brazil
tgoulart
New poster

Posts: 42
Joined: Sat Oct 21, 2006 8:37 am
Location: Alegrete, Brazil

Thanks a lot man....got accepted.
Viswanathan V
New poster

Posts: 8
Joined: Mon Jan 22, 2007 9:08 pm

If you got AC, remove your code plz..
helloneo
Guru

Posts: 516
Joined: Mon Jul 04, 2005 6:30 am
Location: Seoul, Korea

### Re: 10302 - Summation of Polynomials

whats the problem of the formula (n*(n+1)/2)^2 ???
i got AC.but using another formula to solve it.
anyone can explain me whats happen with this formula???
faiem
New poster

Posts: 14
Joined: Fri Aug 13, 2010 12:22 pm

### Re: 10302 - Summation of Polynomials

please can anyone tell me why this code is WA ???

#include<iostream>
using namespace std;
int main()
{
long long n;
while(cin>>n)
{
long long N;
long long result=0;
long long sum =0;
for(int i=1;i<=n;i++)
{
while(sum<(i*i*i))
{
N=1;
sum+=(N*N*N);
N++;
}
result+=sum;
}
cout<< result<<endl;
}
return 0;
}
3sam
New poster

Posts: 6
Joined: Mon Apr 09, 2012 8:33 pm

### Re: 10302 - Summation of Polynomials

Input 50000, AC Output 1562562500625000000
brianfry713
Guru

Posts: 1870
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Previous