913 - Joana and the Odd Numbers
Posted: Mon May 23, 2011 3:59 pm
Hi, can anyone please help me here? I know this is a very easy problem and I could easily find the relation(there is a sequence) and found out the last term. And then sum of the last three terms would be (last term * 3) - 6.
The judge keeps giving me Wrong Answer for apparently some strange reason, I can't figure this out so may be a little help?? Thanks a lot guys.....Im pasting my source code below:
#include <stdio.h>
#include <math.h>
int main()
{
double t, i, j, k, l, x, y, z, sum, a, d;
long long int n;
for (;
{
if (scanf("%lld", &n) == EOF)
break;
if (n <= 1)
break;
if (n % 2 == 0)
break;
sum = 0;
a = 6;
x = ( (n - 1) / 2.0);
y = (x / 2.0) * (12.0 + ( (x - 1) * (4.0) ) );
sum = (3 * y) - 3;
printf("%0.0lf\n", sum);
}
return 0;
}
The judge keeps giving me Wrong Answer for apparently some strange reason, I can't figure this out so may be a little help?? Thanks a lot guys.....Im pasting my source code below:
#include <stdio.h>
#include <math.h>
int main()
{
double t, i, j, k, l, x, y, z, sum, a, d;
long long int n;
for (;

{
if (scanf("%lld", &n) == EOF)
break;
if (n <= 1)
break;
if (n % 2 == 0)
break;
sum = 0;
a = 6;
x = ( (n - 1) / 2.0);
y = (x / 2.0) * (12.0 + ( (x - 1) * (4.0) ) );
sum = (3 * y) - 3;
printf("%0.0lf\n", sum);
}
return 0;
}