add 3032 (joc)
This commit is contained in:
parent
50bae9107f
commit
cf40dce705
1 changed files with 25 additions and 0 deletions
25
3032/solutie.cpp
Normal file
25
3032/solutie.cpp
Normal 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;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue