fork(24) download
  1. #include <cstdlib>
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. int n, x;
  9. cin >> n >> x;
  10. int a[n+1];
  11. for (int i = n; i >= 0; --i)
  12. {
  13. cin >> a[i];
  14. }
  15. int s = a[n];
  16. for (int i = 1; i <= n; ++i)
  17. {
  18. s *= x;
  19. s += a[n-i];
  20. }
  21. cout << s << endl;
  22. }
Success #stdin #stdout 0s 3300KB
stdin
3	2	5	4	3	2
stdout
64