can anybody tell why wrong answer
or
pls give me for some input && ouput
Code: Select all
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
int main()
{
long k,count,i,pre,sum,j;
long p[15000],q[15000];
char str[100000] , *pointer,ch;
//freopen("c:\\10719.in","r",stdin);
while(scanf("%ld",&k)!= EOF)
{
//scanf("%c",&ch);
gets(str);
gets(str);
count = -1;
pointer = strtok(str," -");
while(pointer)
{
p[++count] = atol(pointer);
pointer = strtok(NULL, " ");
}
pre = 0;
printf("q(x):");
for(i = 0;i<count;i++)
{
pre = p[i] + pre*k;
printf(" %ld",pre);
}
sum = 0;
for(i = 0,j = count;i<=count;i++,j--)
sum += p[i] * pow(k,j);
printf("\nr = %ld\n",sum);
printf("\n");
}
return 0;
}