Created
July 5, 2016 16:17
-
-
Save varundey/6e4f40517262038f0d6b4d51e05d551e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <math.h> | |
void val(long long int k, long long int coeff[], long long int deg){ | |
long long int ans=0,p; | |
for(int i=0;i<=deg;i++){ | |
double ow = pow(k,i); | |
p = (int)ow; | |
ans+=coeff[i]*p; | |
printf("%lld",ans); | |
} | |
} | |
int main(){ | |
long long int n,q,x; | |
long long int coeff[1000000]; | |
scanf("%lld",&n); | |
for(int i=0;i<=n;i++){ | |
scanf("%lld",&coeff[i]); | |
} | |
scanf("%lld",&q); | |
while(q--){ | |
scanf("%lld",&x); | |
val(x, coeff, n); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment