fork(3) download
  1. #include<stdio.h>
  2. #include<math.h>
  3. #include <iostream>
  4.  
  5. int main(){
  6.  
  7. int d;
  8. int n;
  9. int x;
  10.  
  11. scanf("%d", &d);
  12. for(int i = 0; i < d; ++i){
  13. scanf("%d", &n);
  14.  
  15. int t[n];
  16.  
  17. for(int j=0;j<n+1;j++)
  18. std::cin>>t[j];
  19.  
  20. scanf("%d", &x);
  21.  
  22. int i;
  23. int w = 0;
  24.  
  25. for(int k=0; k<=n; k++){
  26. w *= x;
  27. w += t[k];
  28. }
  29.  
  30. if(i!=(d-1))
  31. printf("%d\n",w%1243);
  32. else
  33. printf("%d ppp",w%1243);
  34. }
  35. return 0;
  36. }
Success #stdin #stdout 0.02s 2728KB
stdin
2
4
1 2 0 1 0
2
4
1 1 1 1 1
6
stdout
34
312