diff --git a/UPCODER/Server thi/LTNC2024.CA1.CAU2.cpp b/UPCODER/Server thi/LTNC2024.CA1.CAU2.cpp new file mode 100644 index 00000000..09f9c6bc --- /dev/null +++ b/UPCODER/Server thi/LTNC2024.CA1.CAU2.cpp @@ -0,0 +1,36 @@ +#include +using namespace std; + +int main() { + freopen("botheso.inp", "r", stdin); + freopen("botheso.out", "w", stdout); + + int n, du = 0; + stack s; + cin >> n; + + vector 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; +} \ No newline at end of file