Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
tynnp authored Jun 18, 2024
1 parent f7ea1da commit 79505f8
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions UPCODER/Server thi/LTNC2024.CA1.CAU2.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#include <bits/stdc++.h>
using namespace std;

int main() {
freopen("botheso.inp", "r", stdin);
freopen("botheso.out", "w", stdout);

int n, du = 0;
stack<int> s;
cin >> n;

vector<int> v(n);
for (int &x : v) cin >> x;
reverse(v.begin(), v.end());

for (int x : v) {
x = x*2 + du;
du = 0;

if (x > 9) {
x %= 10;
du = 1;
}

s.push(x);
}

if (du > 0) s.push(du);

while (!s.empty()) {
cout << s.top() << endl;
s.pop();
}

return 0;
}

0 comments on commit 79505f8

Please sign in to comment.