25 lines
383 B
C++
25 lines
383 B
C++
#include <fstream>
|
|
|
|
using namespace std;
|
|
|
|
ifstream fin("joc.in");
|
|
ofstream fout("joc.out");
|
|
|
|
int main() {
|
|
int x, n, a=0, ant=0;
|
|
fin >> n >> x;
|
|
ant = x;
|
|
for (int i = 0; i < n; i++) {
|
|
fin >> a;
|
|
ant = x;
|
|
if (a == 1) {
|
|
x = x * 2;
|
|
} else if (a == 2) {
|
|
x = ant*3 + 1 + x;
|
|
} else if (a == 3) {
|
|
x = x / 2;
|
|
}
|
|
}
|
|
fout << x;
|
|
return 0;
|
|
}
|