Skip to content

Instantly share code, notes, and snippets.

@varundey
Created July 5, 2016 16:17
Show Gist options
  • Save varundey/6e4f40517262038f0d6b4d51e05d551e to your computer and use it in GitHub Desktop.
Save varundey/6e4f40517262038f0d6b4d51e05d551e to your computer and use it in GitHub Desktop.
#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