yuh well now im just confused...
here is my final code that i submitted to the judge and got a "wrong answer" reply to...
Code:
/* CSC1140@ 07611201 74kzYkXl 10523 */
#include <stdio.h>
int main(int argc, char* argv[])
{
int n,a;
int calc,sum,x,i,final_a,count=0;
while(scanf("%d %d",&n,&a) == 2)
{
count++;
sum = 0;
for(i=1; i<=n; i++)
{
final_a = a;
if(i == 1)
{
}
else
{
for(x=1;x<i;x++)
{
final_a = final_a * a;
}
}
calc = i * final_a;
sum = sum + calc;
}
if(count == 1)
{
printf("%d",sum);
}
else
{
printf("\n%d",sum);
}
}
return 0;
}
i know its probably over-complicated; but it was all i could think of to make sure there were no extra "\n" at the end of output.
I tested it for many different inputs and the output is correct each and every time...