You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
400 B
22 lines
400 B
#include <bits/stdc++.h>
|
|
|
|
using namespace std;
|
|
|
|
int a[11] = {0};
|
|
|
|
int main() {
|
|
int n, x;
|
|
cin >> n >> x;
|
|
for (int i = 0; i <= n; ++i) {
|
|
cin >> a[i];
|
|
}
|
|
int sum = 0;
|
|
for (int i = n; i >= 1; i--) {
|
|
sum += a[i] * pow(x, i);
|
|
cout << a[i] << " " << (int) pow(x, i) << endl;
|
|
}
|
|
sum += a[0];
|
|
cout << sum << endl;
|
|
return 0;
|
|
}
|