add 3032 (joc)

This commit is contained in:
fzorb 2025-05-10 20:55:49 +03:00
parent 50bae9107f
commit cf40dce705

25
3032/solutie.cpp Normal file
View file

@ -0,0 +1,25 @@
#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;
}