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
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
Please, if some of you got the correct answer for this "stupid" problem, can you post examples with extralarge 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...
Thanks in advance!
I think i'm near the correct answer, only a rare overflow output may be the reason of my wrong answers...
Thanks in advance!
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.
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.
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.
& in long double the output for 50000 is 1562562500624999900.

 New poster
 Posts: 2
 Joined: Sat Jun 04, 2005 10:07 pm
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
Can someone explain me how to do that? I would be grateful...
Thanks
10302 [Polynomials] getting WA?
Here is the code
use long long to get AC.
Code: Select all
removed after AC
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
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

 New poster
 Posts: 8
 Joined: Mon Jan 22, 2007 9:08 pm
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>
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.

 New poster
 Posts: 8
 Joined: Mon Jan 22, 2007 9:08 pm
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???
i got AC.but using another formula to solve it.
anyone can explain me whats happen with this formula???
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;
}
#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;
}

 Guru
 Posts: 5947
 Joined: Thu Sep 01, 2011 9:09 am
 Location: San Jose, CA, USA
Re: 10302  Summation of Polynomials
Input 50000, AC Output 1562562500625000000
Check input and AC output for thousands of problems on uDebug!