Ladies_Man

1_Polynomial eq.

Dec 15th, 2013
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.31 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5.     int i = 0, n;
  6.     long int x, a, p, pr;
  7.     scanf ("%d%ld%ld", &n, &x, &a);
  8.     p = a; pr = a*n;
  9.     for (i = n; i > 0; i--) {
  10.         scanf ("%ld", &a);
  11.         p = p*x + a;
  12.         if (i > 1) pr = a*(i - 1) + pr*x;
  13.     }
  14.     printf ("%ld %ld", p, pr);
  15.     return 0;
  16. }
Advertisement
Add Comment
Please, Sign In to add comment